Custom Post Type Capabilities

Ok – lets try this again 🙂

I added the map_meta_cap parameter which is needed to have delete_others_posts work. Now I was able to get authors to edit and view all posts but only delete their own.

$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' ),
    'map_meta_cap'  => true,
    'capabilities'  => array(
        'read_post' => 'read_post',
        'edit_post' => 'edit_posts',
        'edit_posts' => 'edit_posts',
        'edit_others_posts'     => 'edit_posts',
        'delete_others_posts'   => 'install_plugins',
    )

);
register_post_type( 'book', $args );