How can we exclude editors from changing Content Blocks?
-
Hi,
If we create a new User Role that can edit posts how do we exclude the role from editing Content Blocks?
Here is the code we tried in functions.php. It creates a new user role we called “Post Editor.” But they can still edit all custom post types including Content Blocks. We’re trying to exclude Content Blocks. Any idea how we do that?
We retried naming this capability edit_content_block, edit_content_blocks, edit_custom-post-type but they still showed up in the dashboard of our new “Post Editor”.
We’ll understand if this is beyond your expertise!
function add_role_post_editor(){
if ( get_option( ‘role_post_editor_version’ ) !== 1 ){ // this prevent running on each pageload
update_option( ‘role_post_editor_version’, 1 );$post_editor_capabilities = array(
‘edit_posts’ => true,
‘edit_others_posts’ => true,
‘edit_published_posts’ => true,
‘read’ => true,
‘read_custom-post-widget’ => false,
‘edit_custom-post-widget’ => false,
‘edit_custom-post-widget’ => false,
‘edit_custom-post-widget’ => false,
);
add_role( ‘post_editor’, ‘Post Editor’, $post_editor_capabilities );
}
}add_action( ‘init’, ‘add_role_post_editor’ );
- The topic ‘How can we exclude editors from changing Content Blocks?’ is closed to new replies.