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,
Yes, this is possible. Comment moderation is an option, and is retrieved like any other option:
the get_option function applies a filter before returning the value…
So what you’ll want to do is
add_filter('option_comment_moderation', 'check_moderable_post_types')
and in yourcheck_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:
The previous answer doesn’t work for me in WordPress 4.9.8. I figured it out with the help of
pre_comment_approved
hook.Example: