wp_new_comment_notify_postauthor

Send a notification of a new comment to the post author.

Description

wp_new_comment_notify_postauthor( (int) $comment_ID ); 

Parameters (1)

0. $comment_id (int)
The comment id.

Usage

  1. if ( !function_exists( 'wp_new_comment_notify_postauthor' ) ) { 
  2. require_once ABSPATH . WPINC . '/comment.php'; 
  3.  
  4. // The comment id. 
  5. $comment_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_new_comment_notify_postauthor($comment_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/comment.php  
  1. function wp_new_comment_notify_postauthor( $comment_ID ) { 
  2. $comment = get_comment( $comment_ID ); 
  3.  
  4. $maybe_notify = get_option( 'comments_notify' ); 
  5.  
  6. /** 
  7. * Filters whether to send the post author new comment notification emails,  
  8. * overriding the site setting. 
  9. * @since 4.4.0 
  10. * @param bool $maybe_notify Whether to notify the post author about the new comment. 
  11. * @param int $comment_ID The ID of the comment for the notification. 
  12. */ 
  13. $maybe_notify = apply_filters( 'notify_post_author', $maybe_notify, $comment_ID ); 
  14.  
  15. /** 
  16. * wp_notify_postauthor() checks if notifying the author of their own comment. 
  17. * By default, it won't, but filters can override this. 
  18. */ 
  19. if ( ! $maybe_notify ) { 
  20. return false; 
  21.  
  22. // Only send notifications for approved comments. 
  23. if ( ! isset( $comment->comment_approved ) || '1' != $comment->comment_approved ) { 
  24. return false; 
  25.  
  26. return wp_notify_postauthor( $comment_ID );