[wp-trac] [WordPress Trac] #46181: Meta capabilities are not mapped completely when registering custom post type

WordPress Trac noreply at wordpress.org
Mon Feb 4 11:37:30 UTC 2019


#46181: Meta capabilities are not mapped completely when registering custom post
type
-----------------------------+--------------------------------------
 Reporter:  dingo_d          |      Owner:  (none)
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Role/Capability  |    Version:
 Severity:  normal           |   Keywords:  dev-feedback 2nd-opinion
  Focuses:                   |
-----------------------------+--------------------------------------
 When you register a custom post type (CPT), and set a capability to some
 string, you won't have `delete_posts` and `delete_others_posts` meta
 capabilities present, which will cause a PHP notice:

 > PHP Notice:  Undefined property: stdClass::$delete_posts in /public_html
 /wp-admin/includes/class-wp-posts-list-table.php on line 400

 I registered a `documentation` CPT and set

 {{{#!php
 <?php
 add_action(
   'init',
   function() {
     register_post_type(
       'documentation',
       [
         ...,
         'capability_type' => 'documentation',
         'map_meta_cap' => false,
       ]
     );
   }
 );
 }}}


 Instead, I need to define custom `capabilities` array to avoid this error
 (and add the two).

 Shouldn't this be done automatically?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46181>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list