I have added a Custom Post Type as follows
add_action( 'init', 'codex_book_init' );
function codex_book_init() {
$args = array(
'description' => __( 'Description.', 'your-plugin-textdomain' ),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'book' ),
'capability_type' => 'post',
'capabilities' => array(
'edit_published_posts' => 'do_not_allow' ), //No permission to edit published post, but have permission to delete post
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )
);
register_post_type( 'book', $args );
}
Now when a book post type post is added and published, there is no checkbox in post list table to select multiple post at once. I do not have permission to edit but have permission to delete. So i should have checkbox to select multiple posts and delete.
in Wp_Posts_List_Table method which outputs checkbox
public function column_cb( $post ) {
if ( current_user_can( 'edit_post', $post->ID ) ): ?>
<label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php
printf( __( 'Select %s' ), _draft_or_post_title() );
?></label>
<input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
<div class="locked-indicator"></div>
<?php endif;
}
So users must have ‘edit_post’ capability to get that checkbox, but why? how to overcome this?