How to add additional e-mail addresses to WordPress comment notifications

By default, WordPress will notify only the actual post author if there are new comments on their post. But what if you want to notify additional people about every comment posted on the website? Like site editors, for example?

This is just a quick filter you can use in this case:

function filter_comment_notification_headers( $message_headers )
{
    $notify_other_people = array(
        '"John Smith" <john.smith@email.address>',
        '"Jane Smith" <jane.smith@email.address>'
    );

    $message_headers .= "\n" .
        'CC: ' . implode(', ', $notify_other_people );

    return $message_headers;
}
add_filter('comment_notification_headers', 'filter_comment_notification_headers');

About aesqe

Wowee, wowee!
This entry was posted in News and tagged , , , , . Bookmark the permalink.

4 Responses to How to add additional e-mail addresses to WordPress comment notifications

  1. Marcelo Araujo says:

    great tip!

  2. aesqe says:

    Updated the code, haven’t noticed that WP had stripped out the e-mail addresses because the brackets weren’t encoded- sorry about that :|

  3. Marcelo Araujo says:

    in what file i must add this code? tks!

    • aesqe says:

      you should put this code either in your theme’s “functions.php file” (in your theme’s directory), or include it in a plugin.

      and sorry it took me so long to reply, Marcelo :|

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>