[wp-hackers] Custom post type capabilities, but needs 'edit_posts' as well?

Andrew Nacin wp at andrewnacin.com
Wed Jun 30 00:13:31 UTC 2010


On Tue, Jun 29, 2010 at 8:05 PM, Alex Hempton-Smith <hempsworth at gmail.com>wrote:

> Wouldn't it be more flexible to possibly have an extended array in
> the register_post_type() args, like this:
>
> $args = array(
>  'capabilities' => array(
>  'edit_posts' => 'add_finances',
>  'delete_posts' => 'add_finances',
>  'delete_published_posts' => 'manage_finances'
>  ),
>  'rewrite' => false ...
>
> etc etc


You can do that already.

Simple capability management: pass capability_type.

Advanced capability management: pass capabilities, an array of capabilities
keyed (exactly how you described it) with edit_post, edit_posts,
edit_others_posts, delete_post, publish_posts, read_post,
read_private_posts. See get_post_type_capabilities() and
register_post_type(), both in wp-includes/post.php.

Note that the meta capabilities have no special mapping/handling that
(edit|delete|read)_post have, when capability_type != post. That will likely
come as an option in 3.1, but you can add that through a filter on
map_meta_cap if you are so inclined.


More information about the wp-hackers mailing list