WordPress Discussion: Customize WordPress notification e-mails

It can be tricky as only the site admin will receive an email when a comment is held for moderation. This can be changed.

WordPress Discussion settings: Email me whenever Before a comment appears
WordPress Discussion settings: Email me whenever, Before a comment appears.

Adding custom e-mail addresses for comment moderation or when anyone posts a comment.

When the two following Email me whenever settings are checked:

Anyone posts a comment – The post author will receive a notification.
A comment is held for moderation – The main site admin will receive an e-mail.

We might want to change whom receives the email to moderate a comment. The following code makes it possible to add multiple e-mail addresses for notification of a new post as well as moderation of a new post.

// https://web.archive.org/web/20200216075253/http://www.sourcexpress.com/customize-wordpress-comment-notification-emails/
function se_comment_moderation_recipients( $emails, $comment_id ) {
    // Add any email. Replace email1,2 and 3 with your own e-mail addresses.
$emails[]=  'email1' ;
$emails[] = 'email2' ;
$emails[] = 'email3' ;
    return $emails;
// Hook to notify as well as moderate a new post. //https://developer.wordpress.org/reference/hooks/comment_notification_recipients/
add_filter( 'comment_notification_recipients', 'se_comment_moderation_recipients', 11, 2 );
add_filter( 'comment_moderation_recipients', 'se_comment_moderation_recipients', 11, 2 );

Before a comment appears

Comment must be manually approved
All comments must be manually approved by a site user or site admin that have the correct user role.

Comment author must have a previously approved comment
The comment will be posted right away if the author’s email address have previously approved comments.
If not then the comment will be held for moderation.

A big thank you to Michal Bluma and Dovid Levine at the Facebook Advanced WordPress group. For helping me get the code correct.


WordPress documentation: Settings Discussion Screen
Sourcexpress: Customize WordPress comment notification e-mails
WordPress documentation: Add filter
WordPress developer reference: Hooks Comment Notification recipients
WordPress developer reference: Hooks Comment Moderation recipients

Share the article:

Leave a Reply

Your email address will not be published. Required fields are marked *