[wp-hackers] Capabilities and all that
johnbillion+wp at gmail.com
Mon Jul 23 15:22:52 UTC 2012
On 23 July 2012 15:48, Simon Wheatley <simon at sweetinteraction.com> wrote:
> I was hoping for a neat way of using map_meta_cap or similar to allow anyone with a *_posts(s) type cap to carry that cap over to the *_video(s) caps.
> Any tips, or do I have to add all the *_video(s) caps to all the roles in the site I want to have them.
Take a look at my User Switching plugin . It uses the
'user_has_cap' and 'map_meta_cap' filters for adding capabilities on
the fly and I've documented it well because it can be hard to get your
I would use *_video as your CPT's meta capability, assign these
capabilities to your Video Editor role when you add the custom role,
and then filter the capabilities for all your other roles so you don't
need to touch them. Something along the lines of:
if ( ( 'edit_video' == $args ) and !isset( $caps['edit_video'] ) )
$caps['edit_video'] = user_can( $args, 'edit_posts' );
More information about the wp-hackers