I have created a custom post type in a plugin for a site I'm working on. I'm allowing users assigned a custom role to add/edit/delete the custom post type. I would like to give these users as little functionality as possible in the admin beyond posting.
So I've used remove_meta_box
to remove a few panels on the conversation post edit screen for these users via a plugin. One of the meta boxes I've disabled is commentsstatusdiv which includes the form elements for comment status and trackbacks.
It seems that if the comments status form element is missing, the comment_status
field gets set to off. I'd like to default comments on for the post type and prevent users in this role from changing the comments setting. But when the users save the post comment status is set to off.
I can force a setting with the wp_insert_post_data
filter. But I don't want to override for admins. I'd like admins to have control.
How do I force comments status to be on by default and prevent users of a specific role from changing it while still allowing admins to turn them on/off?
current_user_can( 'limited_role_name' )
before you enforce the comment status.