落絮飞雁

顺流而下,把梦做完

评论回复后邮件通知——无插件实现

还是利用函数function.php文件实现。

添加:

//comment_mail_notify
function comment_mail_notify($comment_id) {
  $comment = get_comment($comment_id);
  $parent_id = $comment->comment_parent ? $comment->comment_parent : '';
  $spam_confirmed = $comment->comment_approved;
  if (($parent_id != '') && ($spam_confirmed != 'spam')) {
    $wp_email = 'no-reply@' . preg_replace('#^www.#', '', strtolower($_SERVER['SERVER_NAME']));//发件人e-mail地址
    $to = trim(get_comment($parent_id)->comment_author_email);
    $subject = '您在['.get_option("blogname").']的留言有了回复';
    $message = '

 

‘.trim(get_comment($parent_id)->comment_author).’, 您好!

 

这是您在《’.get_the_title($comment->comment_post_ID).’》中的留言:
‘ .trim(get_comment($parent_id)->comment_content).’

 

以下是’.trim($comment->comment_author).’ 给您的回复:
‘ .trim($comment->comment_content).’

 

您可以点击这里查看回复的完整内容.

 

‘ . get_option(‘blogname’) . ‘内容已经更新,欢迎再度光临!

 

此邮件为系统发出,请勿回复此邮件!

 

任何疑问,欢迎邮件admin@luoxufeiyan.com

 

‘; $from = “From: “” . get_option(‘blogname’) . “” <$wp_email>”; $headers = “$fromnContent-Type: text/html; charset=” . get_option(‘blog_charset’) . “n”; wp_mail( $to, $subject, $message, $headers ); //echo ‘mail to ‘, $to, ‘
‘ , $subject, $message; // for testing } } add_action(‘comment_post’, ‘comment_mail_notify’); //comment_mail_notify end

即可。
参考自:wordpress 3.8 不使用插件,实现email通知访客其评论有人回复——老牛博客


原文标题:评论回复后邮件通知——无插件实现|落絮飞雁的个人网站
原文链接:https://www.luoxufeiyan.com/2015/02/05/comment_mail_notify/
授权协议:创作共用 署名-非商业性使用 2.5 中国大陆
除注明外,本站文章均为原创;转载时请保留上述链接。