Need to send an email to all subscribers regarding new comments that have been left

I know that users can get emails sent to them any time a comment is left on a specific post, but I need to be able to send the email to all users for any comment that is made on any post. We create events with events+ and comments are left all the time, but we don’t want our members to have to go to each event and subscribe to comments for this particular event. Ideally we would have a way for users to “opt in” for email for any comment left on any post. Although not a requirement at this point, the ability to “opt out” of emails for any comment would be good too. I have been looking for a plugin to help with this but am coming up blank.

  • Phil
    • The Incredible Code Injector


    I did see both of these but they do not do what I need. Each of these still require the user to subscribe to the post. I need every user to get every email about every post. They should not need to subscribe to anything. The only think I am sure I will need to be able to do in the future, is allow them to “unsubscribe”. I am sure there must be a way to create a filter that calls a function each time a comment is left, regardless of what post it was left on. This function would simply email all users regarding the comment left.

  • aristath
    • Recruit

    Hello again @phil,

    I’ve got the impression that the action you’re looking for is edit_post.

    According to the WordPress codex on :

    Runs when a post or page is updated/edited, including when a comment is added or updated (which causes the comment count for the post to update). Action function arguments: post or page ID.

    So something like this should work:


    function custom_notify_post_update( $post_id ) {

    // Get the post object
    $post = get_post( $post_id );

    // Get an array of users
    $users = get_users();

    foreach ( $users as $user ) {
    // Get the user's email
    $email = $user->user_email

    // The email subject
    $email_subject = "New activity.";

    ob_start(); ?>

    <title>New activity on <?php bloginfo( 'name' ) ?></title>
    Hi <?php echo $author->user_firstname ?>,
    See <a href="<?php echo get_permalink($post->ID) ?>"><?php the_title_attribute() ?> for more details</a>.


    $message = ob_get_contents();


    wp_mail( $email, $email_subject, $message );


    add_action( 'edit_post', 'custom_notify_post_update' );

    Please note though that this will add an action that will send an email to ALL your users when a new comment has been published, or when a new post is published.

    If you have a lot of members, this can result in a significant delay when publishing a comment…

    I hope that helps!



Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.