Email PHP Beginner

Send Comment Moderation Emails to Someone Else

Send "Please moderate" comment emails to an editor or a shared inbox instead of the site admin email.

Tested on WordPress 7.1 PHP 8.3 No plugin needed Updated
functions.php 3 lines
add_filter( 'comment_moderation_recipients', function ( array $emails, int $comment_id ): array {
	return [ 'comments@example.com' ];
}, 10, 2 );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

Comments waiting for approval are emailed to the site admin address and the post author. If someone else handles comments, like a community manager, the emails should go to them.

How it works

WordPress passes the list of moderation email addresses through comment_moderation_recipients. The snippet replaces it with your own list. Add more addresses to the array if several people moderate.

Things to watch

  • Settings → Discussion → “A comment is held for moderation” must still be ticked for any email to be sent.
  • Use an address on your own domain, or a @gmail.com address may be marked as spam.

How to test it

Leave a comment that needs approval. The moderation email should arrive at your chosen address.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only