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

Alex Hempton-Smith hempsworth at gmail.com
Wed Jun 30 00:28:05 UTC 2010


Cheers Andrew,

I'm certainly getting somewhere but it's not quite working. I have the
following array in register_post_type

    'capabilities' => array(
 'edit_posts' => 'manage_finances',
'delete_posts' => 'manage_finances',
 'delete_published_posts' => 'manage_finances',
'publish_posts' => 'manage_finances',
 'edit_published_posts' => 'manage_finances'
),

So the user can view the post screen, but when a post is saved, the user is
directed to example.com/wp-admin/post.php with the message "You are not
allowed to edit this post." - although that cap has been added?

Any ideas?

-- Alex  (Hempsworth)


On Wed, Jun 30, 2010 at 1:13 AM, Andrew Nacin <wp at andrewnacin.com> wrote:

> 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.
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list