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
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.