Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

vatanbytyqi on "Disable email notifications for custom post type when commenting"

$
0
0

Hi,

I'm working on a plugin and have a custom post type and when someone makes a comment I don't want to send an email to admin telling that a new comment need attention. But I don't want to disable the notifications for all post type only for my custom type. I have tried some codes that I have found here on the forum but it is not working for me, I still get the notifications.

This is what I have tested so far:

add_action('comment_post', 'my_custom_commment');
function my_custom_commment($comment_id){
    global $cache_settings;
    $comment = get_comment($comment_id);
    $post = get_post($comment->comment_post_ID);
    if ( $post->post_type=="my_custom_type" ) {
        $foo = get_settings('comments_notify'); // make sure it's cached
        $cache_settings->comments_notify = 0;
    }
}

Thanks in advance!
Vatan


Viewing all articles
Browse latest Browse all 8245

Trending Articles