Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I know that I can require all of the comments on my site to be moderated, but is there a way of forcing moderation for a specific custom post type (i.e. my CPT "species") whilst allowing instantaneous comments across the rest of the site?

Thanks in advance,

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Yes, this is possible. Comment moderation is an option, and is retrieved like any other option:

get_option('comment_moderation');

the get_option function applies a filter before returning the value...

return apply_filters( 'option_' . $option, maybe_unserialize( $value ) );

So what you'll want to do is add_filter('option_comment_moderation', 'check_moderable_post_types') and in your check_moderable_post_types function, check to see if the current post's post type is species. If so, return 1, and if not return the $value that is passed to the function!

Edit: This should do the trick:

add_filter('option_comment_moderation', 'check_moderable_post_types');
function check_moderable_post_types($value) {
    if (get_post_type() == 'species') return 1;
    return $value;
}
share|improve this answer
    
Hi Matthew, thanks for this - works perfectly. Much appreciated! –  dunc Jan 22 '12 at 20:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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