Modify Recipients in WordPress Comment Notification / Moderation Mails

If you want to change the recipients that receive comment notification and comment moderation mails, you can use this snippet:

function replace_recipient($recipients, $comment_id) {
	return ['changed_recipient@example.com'];
}

add_filter('comment_moderation_recipients', 'replace_recipient', 10, 2);
add_filter('comment_notification_recipients', 'replace_recipient', 10, 2);

If you would like to add additional recipients to the comment notification and comment moderation mails, you can use this snippet:

function add_additional_recipient($recipients, $comment_id) {
	$recipients[] = 'additional_recipient@example';
	
    return $recipients;
}

add_filter('comment_moderation_recipients', 'add_additional_recipient', 10, 2);
add_filter('comment_notification_recipients', 'add_additional_recipient', 10, 2);