WordPress Tutorial: Notify reviewers by email after review

 Watson Blog September 11, 2017 12:52:12 WordPress comment one hundred and fifty-three Reading mode

WordPress comes with a function that allows visitors to comment on articles The settings must be approved by the administrator before the comments are displayed. This function is enabled in the background [Settings] ->[Discussion], which can avoid the impact of some garbage comments on the website.

WordPress教程:评论通过审核后邮件通知评论者

When there are comments waiting for approval, WordPress will automatically send a notification email to the webmaster, but after the comments are approved by the webmaster, WordPress does not send notifications to reviewers, which will cause some inconvenience to normal reviewers.

How to send a notification email to the reviewer after the review? We can add the following PHP code in functions.php of the current topic:

  1. /**  
  2. *WordPress Tutorial: Notify reviewers by email after review  
  3. * http://wosn.net/490.html  
  4. */   
  5. add_action('comment_unapproved_to_approved', 'wosn_net_comment_approved');   
  6. function  wosn_net_comment_approved( $comment ){  
  7.      if  (is_email( $comment ->comment_author_email)){  
  8.          $post_link  = get_permalink( $comment ->comment_post_ID);   
  9.          $title ='Your comment on ['. get_bloginfo ('name ').'] has been approved ';   
  10.          $body ='In the<a href= "' . $post_link . '"  target= "_blank"  >' .  get_the_title( $comment ->comment_post_ID) . '</a>has passed the review< br /><br />';   
  11.          $body  .= '<strong>Your comments:</strong><br/>';   
  12.          $body  .=   strip_tags ( $comment ->comment_content) .  '<br /><br />';   
  13.          $body  .= 'You can:<a href= "' . get_comment_link($comment->comment_ID) . '"  target= "_blank" >View your comments</a>|<a href= "' . $post_link . '#comments"  target= "_blank" >View other comments</a>|<a href= "' . $post_link . '"  target= "_blank" >Read the article again</a><br/><br/>';   
  14.          $body  .= 'Welcome back [<a href= "' . get_bloginfo('url') . '"  target= "_blank"  title= "' . get_bloginfo('description') . '" >' .  get_bloginfo('name') .  '</a>】。';   
  15.          $body  .= '<br/><br/>Note: This email is automatically sent by the system, please do not reply directly';   
  16.         @wp_mail( $comment ->comment_author_email,  $title $body "Content-Type: text/html; charset=UTF-8" );   
  17.     }  
  18. }  

You can modify the above code according to the content and style you want to reply to.

it's fine too Comment Approved Plug in method. Code method is recommended.

 Watson Blog
  • This article is written by Published on September 11, 2017 12:52:12
  • This article is collected and sorted by the website of Mutual Benefit, and the email address for problem feedback is: wosnnet@foxmail.com , please keep the link of this article for reprinting: https://wosn.net/490.html

Comment