0

Is there any possibility or plugin, that alows me to add a user (example author role) who could add posts but only in one category?

1 Answer 1

0

First remove the category metabox from the post edit screen for this particular role, let's name it onecat-author:

if (current_user_can('onecat-author')) {
  remove_meta_box ('category', 'post', 'normal');   
  }

Next, when the post is saved use the available hook to assign the category:

if (current_user_can('onecat-author')) {
  add_action ('save_post', 'wpse_231846_save_cat', 10, 1 );
  }
function wpse_231846_save_cat ($post_id) {
  wp_set_post_categories ($post_id, array('the-id-of-that-category'));
  }

Note: the code is untested, so some debugging may be necessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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