Defining capabilities for custom post type

On creation of a custom post type I’m trying to define capabilities but it’s not working. What’s wrong with this code?

$args = array(
  'labels' => $labels,
  'public' => true,
  'publicly_queryable' => true,
  'show_ui' => true,
  'query_var' => true,
  'rewrite' => true,
  'hierarchical' => false,
  'menu_position' => null,
  'supports' => array('title'),
  'capabilities' => array(
   'edit_post' => 'edit_video',
   'edit_posts' => 'edit_videos',
   'edit_others_posts' => 'edit_others_videos',
   'publish_posts' => 'publish_videos',
   'read_post' => 'read_videos',
   'read_private_posts' => 'read_private_videos',
   'delete_post' => 'delete_videos'
   )
   );

Related posts

Leave a Reply

2 comments

  1. You code seems to be correct. Try the following instead.

    $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => true,
        'hierarchical' => false,
        'menu_position' => null,
        'supports' => array('title'),
        'capability_type' => 'video'
    );
    

    Update:

    You have to do some extra steps before making it work with the members plugin. See this forum post from Justin Tadlock (developer of the members plugin).
    http://wordpress.org/support/topic/anyone-managed-to-get-custom-post-types-capabilities-working/page/2#post-1593534

    This plugin seems to be doing it automatically:
    http://wordpress.org/extend/plugins/map-cap/