管理员回复留言php,最新WordPress评论邮件通知管理员及回复评论者(详细教程)...

// 评论必须经过审核才会发送通知邮件

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 = ‘

您在’ . get_option(‘blogname’) . ‘ 上的留言有回复啦!

’ . 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);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值