[wp-trac] [WordPress Trac] #14122: Custom "capabilities" appears broken on custom post types

WordPress Trac wp-trac at lists.automattic.com
Sun Jun 27 23:24:31 UTC 2010


#14122: Custom "capabilities" appears broken on custom post types
--------------------------+-------------------------------------------------
 Reporter:  jakemgold     |       Owner:                                        
     Type:  defect (bug)  |      Status:  new                                   
 Priority:  normal        |   Milestone:  Awaiting Review                       
Component:  Post Types    |     Version:  3.0                                   
 Severity:  major         |    Keywords:  capabilities, roles, custom post types
--------------------------+-------------------------------------------------
 It's impossible to create a functional equivalent to a "contributor" role
 unique to a new custom content type, no what approach one takes. Consider
 the code below (the most stripped down code that exemplifies the point):

 {{{
 register_post_type('movies',array(
         'label' => 'Movies',
         'singular_label' => 'Movie',
         'public' => true,
         'capabilities' => array( 'edit_posts' => 'edit_movies' ),
         'supports' => array('title','editor','author')
 ));

 if ( !get_role('producer') )
 {
         global $wp_roles;
         if ( !isset( $wp_roles ) ) $wp_roles = new WP_Roles();

         $caps = $wp_roles->get_role('subscriber')->capabilities;
         $caps = array_merge( $caps, array( 'edit_movies' => true ) );
         $wp_roles->add_role( 'producer', 'Movie Producer', $caps );
 }
 }}}

 Note that the "Movies" admin menu ''does'' appear for the "producer" role,
 along with the "add new" option. However, entering content into the editor
 produces a "not allowed" type error, and hitting "submit for review"
 produces a similar error.

 Even if I'm missing something (maybe with the meta capabilities?) if the
 user is not allowed to edit a content type, they should not be presented
 with the menu options, including "add new".

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14122>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list