// 评论必须经过审核才会发送通知邮件
function ludou_comment_mail_notify($comment_id, $comment_status) {
// 评论必须经过审核才会发送通知邮件
if ($comment_status !== ‘approve’ && $comment_status !== 1)
return;
$comment = get_comment($comment_id);
if ($comment->comment_parent != ‘0’) {
$parent_comment = get_comment($comment->comment_parent);
// 邮件接收者email
$to = trim($parent_comment->comment_author_email);
// 邮件标题
$subject = ‘您在[‘ . get_option(“blogname”) . ‘]的留言有了新的回复’;
// 邮件内容,自行修改,支持HTML
$message = ‘
’ . trim($parent_comment->comment_author) . ‘, 您好!
您于’ . trim($parent_comment->comment_date) . ‘ 在文章《’ . get_the_title($comment->comment_post_ID) . ‘》上发表的评论:
’ . nl2br($parent_comment->comment_content) . ‘
’ . trim($comment->comment_author) . ‘ 于’ . trim($comment->comment_date) . ‘ 给您的回复如下:
’ . nl2br($comment->comment_content) . ‘
您可以点击 comment_parent)). ‘” target=”_blank”>查看回复的完整內容
感谢您对 ’ . get_option(‘blogname’) . ‘ 的关注,如您有任何疑问,欢迎在博客留言,我都会一一解答,么么哒!!!
(此邮件由系统自动发出,请勿回复。)
$message_headers = “Content-Type: text/html; charset=\””.get_option(‘blog_charset’).”\”\n”;
// 不用给不填email的评论者和管理员发提醒邮件
if($to != ” && $to != get_bloginfo(‘admin_email’))
@wp_mail($to, $subject, $message, $message_headers);
}
}
// 编辑和管理员的回复直接发送提醒邮件,因为编辑和管理员的评论不需要审核
add_action(‘comment_post’, ‘ludou_comment_mail_notify’, 20, 2);
// 普通访客发表的评论,等博主审核后再发送提醒邮件
add_action(‘wp_set_comment_status’, ‘ludou_comment_mail_notify’, 20, 2);