Filter hook 'comment_notification_recipients'

in WP Core File wp-includes/pluggable.php at line 1690

View Source

comment_notification_recipients

Filter Hook
Description
Filters the list of email addresses to receive a comment notification. By default, only post authors are notified of comments. This filter allows others to be added.

Hook Information

File Location wp-includes/pluggable.php View on GitHub
Hook Type Filter
Line Number 1690

Hook Parameters

Type Name Description
string[] $emails An array of email addresses to receive a comment notification.
string $comment_id The comment ID as a numeric string.

Usage Examples

Basic Usage
<?php
// Hook into comment_notification_recipients
add_filter('comment_notification_recipients', 'my_custom_filter', 10, 2);

function my_custom_filter($emails, $comment_id) {
    // Your custom filtering logic here
    return $emails;
}

Source Code Context

wp-includes/pluggable.php:1690 - How this hook is used in WordPress core
<?php
1685  		 * @since 3.7.0
1686  		 *
1687  		 * @param string[] $emails     An array of email addresses to receive a comment notification.
1688  		 * @param string   $comment_id The comment ID as a numeric string.
1689  		 */
1690  		$emails = apply_filters( 'comment_notification_recipients', $emails, $comment->comment_ID );
1691  		$emails = array_filter( $emails );
1692  
1693  		// If there are no addresses to send the comment to, bail.
1694  		if ( ! count( $emails ) ) {
1695  			return false;

PHP Documentation

<?php
/**
		 * Filters the list of email addresses to receive a comment notification.
		 *
		 * By default, only post authors are notified of comments. This filter allows
		 * others to be added.
		 *
		 * @since 3.7.0
		 *
		 * @param string[] $emails     An array of email addresses to receive a comment notification.
		 * @param string   $comment_id The comment ID as a numeric string.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/pluggable.php
Related Hooks

Related hooks will be displayed here in future updates.