I am using WordPress comments on a page as a Contact page and I am able to show those comments only to logged in admin.

Now I would like to automatically have any comments placed on my Contact page approved. So, in the front end, I can see all comments placed on that page instead of seeing only the approved comments.

I would love to have a hook in functions.php that works with twenty eleven child theme.

1 Answer
1

Considering that in Settings > Discussion you have this options checked:

comments moderation and whitelist options

The first is comment_moderation and the second comment_whitelist.

Then, it is possible to selectively disable them using the filter pre_option_(option-name), as follows:

add_filter( 'pre_option_comment_moderation', 'wpse_72990_auto_aprove_selective' );
add_filter( 'pre_option_comment_whitelist', 'wpse_72990_auto_aprove_selective' );

function wpse_72990_auto_aprove_selective( $option ) 
{  
    global $post;
    if( $post->ID == 2 ) 
        return 0;

    return $option;
}

Leave a Reply

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