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.

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'
   )
   );
share|improve this question
add comment

2 Answers 2

up vote 9 down vote accepted

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/

share|improve this answer
    
I've tried that too. I'm using a plugin to manage roles and capabilities (tried both Capability Manager and Members). I see a full list of capabilities including those defined by other plugins but when I define my own capabilities they don't show up in the list. –  fxfuture Sep 30 '10 at 5:50
    
See the update I added to my answer. –  sorich87 Sep 30 '10 at 6:32
    
I tried following all the steps outlined in that thread but I couldn't get it to work. The plugin, on the other hand, works beautiful and can be disabled after creating the capabilities. Thanks again :) –  fxfuture Oct 1 '10 at 4:18
    
You are welcome. –  sorich87 Oct 1 '10 at 9:54
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.