Is there a way to create one role with one capability and apply it to some of the custom post types?

What I am doing right now is ending up with applying capabilities to all of the posts..

creating role:

$wp_roles->add_role( 'member', 'Paid Membership', array(
'has_paid' => true,
'has_registered' => true
) );

creating a custom post type (i use a class but you ll get the idea)

AN_Posts::AddPostType( static::post_type, array( 'Group', 'Groups', 'groups' ), array( 'description' => 'A user group', 
'map_meta_cap' => true, 
'capability_type' => 'an_group', 
'capabilities' => array( 'read_post' => 'has_registered',
) ) );

check permission

if ( is_single() && ! current_user_can( 'read_post', $post->ID ) )
    $wp_query->is_404 = true;

Any ideas where i am doing it wrong?


1 Answer 1


According to register_post_type() documentation capability_type argument is used to construct capabilities.

I think since you are customizing it for the post type, its capabilities requirements won't be formed like read_post but like read_an_group.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.