Advertisement
geminilabs

[site-reviews] send email to author after review submission

Aug 6th, 2019
1,438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. /**
  2.  * Sends an email to the review author when a new review is created.
  3.  * Paste this in your active theme's functions.php file.
  4.  *
  5.  * @param \GeminiLabs\SiteReviews\Review $review
  6.  * @return void
  7.  */
  8. add_action('site-reviews/review/created', function ($review) {
  9.     if (empty( $review->email)) {
  10.         return;
  11.     }
  12.     // Change the subject and message as needed
  13.     $subject = "Thank you for your review!";
  14.     $message = "Thank you so much for your review! Here is what you submitted:\n\n".
  15.                "Rating: {$review->rating}-stars\n".
  16.                "Title: {$review->title}\n".
  17.                "Review: {$review->content}";
  18.  
  19.     if (!wp_mail($review->email, $subject, $message)) {
  20.         apply_filters('glsr_log', null, 'The notification to <'.$review->email.'> was not sent. Please verify that your server is able to send emails correctly through WordPress.');
  21.     }
  22. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement