带有自定义发布类型的trash_post操作

时间:2011-11-06 作者:Raoni

我有一个自定义的帖子类型“empresa”,并希望在删除帖子类型(移动到垃圾箱)时发送电子邮件。

我在下面为我的帖子提供了这个功能,我如何使用我的帖子类型“empresa”?

add_action("trash_post", "my_awesome_publication_notification");
function my_awesome_publication_notification($post_id) {
$post = get_post($post_id);
$author = get_userdata($post->post_author);

$author_email = get_post_meta( $post->ID , \'empresa_contato_email\' , true );
$email_subject = "A Sua Empresa foi aprovada!";

ob_start();

include("email_header.php");

?>

<p>
    Hi, <?php echo $author->display_name ?>. I\'ve just published one of your articles
    (<?php echo $post->post_title ?>) on MyAwesomeWebsite!
</p>

<p>
    If you\'d like to take a look, <a href="<?php echo get_permalink($post->ID) ?>">click here</a>.
    I would appreciate it if you could come back now and again to respond to some comments.
</p>

<?php

include("email_footer.php");

$message = ob_get_contents();

ob_end_clean();

wp_mail($author_email, $email_subject, $message);
}

2 个回复
SO网友:Tom J Nowell

请改用wp\\u trash\\u post,并记住{post\\u status}{post\\u type},因此最初它应该是trash\\u empresa而不是trash\\u post,也可以尝试wp\\u trash\\u empresa

SO网友:codekipple

对于任何未来的读者来说,挂钩现在似乎已经从“trash\\u post”改为“wp\\u trash\\u post”trac ticket explaining the name change

结束

相关推荐

Comment Spammed vs Trashed

将评论标记为垃圾邮件和将其丢弃有什么区别?