I hope this isn't just the result of typo on my end, but if it is, I'm not seeing it.

I'm adding a custom post type to my site. Actually I'm adding three. Two of them I'm trying to set custom capabilities for a new class of users.

In my admin panel I cannot get this to register when adding the function block of code below to my theme's functions.php file. However, I comment out all of the capabilities related variables, the new CPT shows just fine in the admin interface. If I uncomment any of the capability related variables, the CPT doesn't show in my admin menu.

There's one other little bit of information. I've got a test page that I'm running a var dump on the custom post type's properties to see if it registers. When I register the CPT with capabilities set, while it doesn't show up as a menu item or doesn't allows me to access the editor for that specific CPT (so it appears to not be set), it DOES however still show up in my var dump AND the capabilities are being set for that specific CPT.

Here's my code:

function nb_register_assignment_CPT() {

    Assignment CPT

  $nb_assignment_labels = array(
    'name' => _x('Assignments', 'post type general name', 'doula'),
    'singular_name' => _x('Assignment', 'post type singular name', 'doula'),
    'add_new' => _x('Add New', 'assignment', 'doula'),
    'add_new_item' => __('Add New Assignment', 'doula'),
    'edit_item' => __('Edit Assignment', 'doula'),
    'new_item' => __('New Assignment', 'doula'),
    'all_items' => __('All Assignments', 'doula'),
    'view_item' => __('View Assignment', 'doula'),
    'search_items' => __('Search Assignments', 'doula'),
    'not_found' =>  __('No assignments found', 'doula'),
    'not_found_in_trash' => __('No assignments found in Trash', 'doula'), 
    'parent_item_colon' => '',
    'menu_name' => __('Assignments', 'doula')

  $nb_assignment_args = array(
    'labels' => $nb_assignment_labels,
    'public' => true,
    'publicly_queryable' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => _x( 'assignment', 'URL slug', 'doula' ) ),
    'has_archive' => true, 
    'hierarchical' => false,
    'menu_position' => 52,
    'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ), 
    'capability_type' => array( 'assignment', 'assignments' ), 
    'capabilities' => array(
            'publish_posts' => 'publish_assignments',
            'edit_posts' => 'edit_assignments',
            'edit_others_posts' => 'edit_others_assignments',
            'delete_posts' => 'delete_assignments',
            'delete_others_posts' => 'delete_others_assignments',
            'read_private_posts' => 'read_private_assignments',
            'edit_post' => 'edit_assignment',
            'delete_post' => 'delete_assignment',
            'read_post' => 'read_assignment'
    'map_meta_cap'=> true 

  register_post_type('assignment', $nb_assignment_args); 


Thanks for looking.

  • I see you creating caps, I don't see you assigning those caps to any role. Do you do that?
    – vancoder
    Commented Apr 23, 2013 at 21:18
  • The assignment of capabilities is not the issue here. (I'm handling that with with a caps manager plugin.) It's simpler than that. I'm just trying to figure out why my CPT's are not showing up in my menus when I have capabilities defined for the CPT.
    – Brent
    Commented Apr 23, 2013 at 22:13
  • I understand the issue. My thought was that you may not be seeing your CPT because you didn't have permission to see your CPT.
    – vancoder
    Commented Apr 23, 2013 at 22:34

1 Answer 1


You probably cannot see the new CPT items in your menu, because you have indicated that they require specific caps, yet you have not assigned those same caps to any role - including your own.

Add the following to your code:

    function my_cpt_add_caps() {
        foreach ( array( 'administrator' ) as $role_name ) {
            $role = get_role( $role_name );
            $role->add_cap( 'edit_assignments' );
    // add selected other caps here

register_activation_hook( __FILE__, 'my_cpt_add_caps' );

On plugin activation we assign your new caps to the admin role. Now, your CPT menu items should be available in the menu. Also, only now will plugins such as Members see these new caps, as a cap must be assigned to some role before it will be acknowledged.

As you are using capability_type in your CPT registration, you can drop the capabilities array, as WP will work this out itself.

  • Very insightful Vancoder. I am going to experiment around with this and then post my findings. Thank you!
    – Brent
    Commented Apr 24, 2013 at 17:11
  • Yep, that worked. Vancoder, thank you for having the grace to continue with the issue even after I told you that you didn't get it. :) I didn't use your suggested code, as I was able to do the same thing with the capabilities manager plguin that I was using. After setting the CPT with the desired capabilities (which caused them to disappear from my admin menus), I went over to my caps manager plugin and set the admin capabilities to be able to read and edit these new CPTs. I then logged out and then logged back in to the admin backend and that did the trick. Thank you again, Vancoder!
    – Brent
    Commented Apr 24, 2013 at 17:27

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.