title: Adding custom capability Wordpress - users can't create new custom post type
body: <p>My problem is that all capabilities work as expected except non admin cannot create new widgets. The Add New button is there but the 'You do not have sufficient permissions' message is shown when clicked. The client has unchecked all standard capabilities like edit_posts (for some other reason before I showed up). So maybe that is the issue? Here is my relevant code:</p>
  
  <pre><code>public static function manage_plugin_cap($action = 'add_cap'){
  
  $roles = get_editable_roles();
  $caps = array('edit_widget','edit_widgets','read_widgets');
  $admin_caps = array('edit_other_widgets','publish_widgets','read_private_widgets','delete_widgets');
  foreach ($GLOBALS['wp_roles']-&gt;role_objects as $key =&gt; $role) {
      if (isset($roles[$key])) {      
          if ($key == 'administrator'){
              foreach ($admin_cap as $c){
                  if ($action=='add_cap')
                      {$role-&gt;add_cap( $c, false );}
                  else  {$role-&gt;{$action}( $c );}
              } 
          }
          foreach ($cap as $c){
              if ($action=='add_cap')
                  {$role-&gt;add_cap( $c, false );}
              else  {$role-&gt;{$action}( $c );}
          }
      }
  }
   }
   register_post_type( $this-&gt;prefix.'_'.$single, $args );
   $args = array(
              'labels'             =&gt; $labels,
              'description'        =&gt; __( 'Description.', $this-&gt;text_domain ),
              'public'             =&gt; true,
              'publicly_queryable' =&gt; true,
              'show_ui'            =&gt; true,
              'show_in_menu'       =&gt; 'edit.php?post_type={$single}',
              'query_var'          =&gt; true,
              'rewrite'            =&gt; array('slug' =&gt; $single,'with_front'=&gt;true ),
              'capability_type'    =&gt; 'widget',
              'has_archive'        =&gt; $plural,
              'can_export'         =&gt; true,
              'hierarchical'       =&gt; false,
              'menu_position'      =&gt; null
   );
  </code></pre>
  
  <p>Does anyone see what I'm missing? I tried adding 'create_widgets' without success and 'publish_widgets' to all roles (even though I don't want them to be able to) and that didn't work either. Thanks!</p>
  
  <p>Edit: I removed 'capability_type' from args. I don't think that is needed when I define add my own (maybe it is only needed when mapping from existing capabilities so wp knows what to name the new ones).</p>
  
  <p>Update: I had a chance to revisit this to try and get it right. 
  I have these elements in my register_post_type array: </p>
  
  <pre><code>'capability_type'    =&gt; 'widget',
  'map_meta_cap'       =&gt; false, 
  </code></pre>
  
  <p>which does seem to work for everything except create_widgets. 
  When I dump $GLOBALS['wp_post_types']['my_cpt'] I get </p>
  
  <pre><code> public 'cap' =&gt; 
      object(stdClass)[434]
        public 'edit_post' =&gt; string 'edit_widget' (length=10)
        public 'read_post' =&gt; string 'read_widget' (length=10)
        public 'delete_post' =&gt; string 'delete_widget' (length=12)
        public 'edit_posts' =&gt; string 'edit_widgets' (length=11)
        public 'edit_others_posts' =&gt; string 'edit_others_widgets' (length=18)
        public 'publish_posts' =&gt; string 'publish_widgets' (length=14)
        public 'read_private_posts' =&gt; string 'read_private_widgets' (length=19)
        public 'create_posts' =&gt; string 'edit_widgets' (length=11)
  </code></pre>
  
  <p>So I'm not sure why it shows 'create_posts' as 'edit_widgets'?</p>