• Resolved atuhbta

    (@atuhbta)


    I apologize if this has been addressed elsewhere. I searched but couldn’t find anything. I would like to receive email notification only if specific users comment. Is this possible?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hey, atuhbta, yep this is definitely possible.

    Please see my sample PHP code below:

    /*Sends email notifications only if from a specific commenter*/
    add_filter('notify_post_author','notice_from_specific_users', 10, 2);
    function notice_from_specific_users ( $maybe_notify, $comment_ID )
    {
    	$commenter_email = get_comment_author_email( $comment_ID );
    	$wanted_email_addresses = array ( "[email protected]" ); 
    	$maybe_notify = (! in_array ( $commenter_email, $wanted_email_addresses )) ? false: true; 
    	return $maybe_notify;
    }

    This will only send an email notification if the desired email address is included in the $wanted_email_addresses array.

    Thread Starter atuhbta

    (@atuhbta)

    Thank you Ian! This works perfectly.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Send Comment Email Notification Only From Specific Users’ is closed to new replies.