How to disable send e-mail notification new comments for some posts

Sorry for my English


You can use notify_moderator and notify_post_author filters to control whether or not the comment notification should be sent - to the moderator or comment author.

add_filter('notify_moderator', 'prefix_filter_sent_comment_notification', 10, 2);
add_filter('notify_post_author', 'prefix_filter_sent_comment_notification', 10, 2);
function prefix_filter_sent_comment_notification( bool $maybe_notify, int $comment_ID ) {
    $comment = get_comment($comment_ID);
    $comment_post = get_post($comment->comment_post_ID);
    // determine, if notification should sent or not
    // return true to send
    // to not, return false
    return some_logic_check( $comment_post ) ? false : $maybe_notify;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.