WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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