I have a custom post type which I want authors to be able to edit others posts but no able to delete others posts. My code as follows:
$labels = array(
'name' => __( 'Book', 'textdomain' ),
'singular_name' => __( 'Book', 'textdomain' ),
'menu_name' => __( 'Books', 'textdomain' ),
'add_new' => __( 'New book', 'textdomain' ),
'add_new_item' => __( 'New book', 'textdomain' ),
'edit_item' => __( 'Edit book', 'textdomain' ),
);
$args = array(
'labels' => $labels,
'public' => true,
'menu_position' => 6,
'menu_icon' => 'dashicons-book',
'has_archive' => true,
'supports' => array( 'title', 'author' ),
'capabilities' => array(
'edit_post' => 'edit_posts',
'read_post' => 'edit_posts',
'delete_post' => 'edit_posts',
'edit_posts' => 'edit_posts',
'edit_others_posts' => 'edit_posts',
'publish_posts' => 'edit_posts',
'read_private_posts' => 'edit_others_posts',
'delete_others_posts' => 'edit_others_posts',
),
);
register_post_type( 'book', $args );
What I am experiencing with the above code is:
- When
'edit_others_posts' => 'edit_posts'
, "mine" tab in admin post editor list doesn't show, and I want it to be always shown. Is it possible to force it back? - Even if
'delete_others_posts' => 'edit_others_posts'
(author users don't have the capability to 'edit_others_posts'), authors can delete others posts. - If I modify the code above with
'edit_others_posts' => 'edit_others_posts'
, "mine" tab shows up but author users still can edit others posts, which confuse me.
I'm really not sure if I am using capabilities the right way or if what I intent to do is possible. Thanks in advance.