Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

Thanks!

share|improve this question
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.