WordPress.org

Make WordPress Core

Opened 7 years ago

Last modified 18 months ago

#30991 closed defect (bug)

Post type object capability 'delete_posts' is referenced in the posts list table but does not exist unless 'map_meta_cap' is set to true for post type — at Initial Version

Reported by: bamadesigner Owned by:
Milestone: 5.4 Priority: normal
Severity: normal Version: 4.1
Component: Posts, Post Types Keywords: has-patch has-unit-tests dev-feedback has-dev-note
Focuses: administration Cc:

Description

I'm getting the following error when viewing the main edit screen of a custom post type:

Undefined property: stdClass::$delete_posts at wp-admin/includes/class-wp-posts-list-table.php:209

When I looked up the line, the following code is run:

if ( current_user_can( $post_type_obj->cap->delete_posts ) ) {

The problem is that the capability, 'delete_posts', is only applied to a post type (via get_post_type_capabilities()) if the 'map_meta_cap' argument is set to true when you're registering the post type (via register_post_type()).

Change History (1)

@jipmoors
7 years ago

isset on capability option check for optional capability

Note: See TracTickets for help on using tickets.