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

WordPress Trac wp-trac at lists.automattic.com
Tue Jun 29 12:16:17 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:  2nd-opinion    
--------------------------+-------------------------------------------------

Comment(by duck_):

 Replying to [comment:3 jakemgold]:
 > "I imagine the errors are due to edit_post being the capability, which
 then goes through map_meta_cap and maybe it determines you need edit_posts
 (instead of edit_movies)?"
 >
 > No. Even if you change the code above to use a completely custom
 "capability_type" (rather than defining granular capabilities) like
 "movie" (which gets "edit_movie", "edit_movies" etc) this same behavior
 persists. Same ability to access Add New screen, same errors in editor and
 upon saving.

 nacin's right. If you use {{{'capabilities' => array( 'edit_posts' =>
 'edit_movies' )}}} then map_meta_cap will see that
 {{{$post_type->capability_type}}} is equal to 'post' and then decide that
 the edit_post maps to edit_posts. On the other hand, if you use
 {{{'capability_type' => 'movie'}}} then map_meta_cap will notice the
 difference and call itself again checking the edit_movie meta-cap, however
 there is no matching case for this and so the default is to return
 edit_movie as the capability required. (In the latter case you could, as
 suggested, hook onto the map_meta_cap filter and check if {{{$cap ==
 'edit_movie'}}} etc.)

 > Even more strange, assigning "edit_movie" (singular) to "producer" (in
 example) as a primitive capability will allow the user to successfully
 save the post, but the editor error still persists. It will also, of
 course, allow the producer to edit other users posts (despite lacking that
 capability), but this is to be expected, I suppose, since it's supposed to
 be a meta capability.

 When capability_type is movie and my producer has the edit_movie
 capability I do not see the autosave error in the editor.

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


More information about the wp-trac mailing list