0

Is there a way (through code or plugin) that can make each editor responsible on editing certain categories of the site

1 Answer 1

0

You can hook into the pre_post_update action hook, and check both post's category and editor. Here's a quick example:

// Hook to save_post to do some checks
add_action( 'pre_post_update','wpse315124_save_post_check' );
function wpse315124_save_post_check( $post_id, $post_data ){
  // Check user's role and post's category
  if( 
        has_category ( 'some-category', $post_id ) &&
        current_user_can( 'editor' )
    ) {
      // Stop the script
      wp_die( __( 'You can not edit this post.' ) );
  }
}

You can also run additional tests, such as get_current_user_id() and check the id to match specific users/categories.

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.