I have created custom post type as below.
register_post_type( 'connector',
array(
'labels' => array(
'name' => __( 'Connectors' ),
'singular_name' => __( 'Connector' ),
'all_items' => __( 'All Connectors' ),
'add_new' => __( 'Add Connector' ),
'add_new_item' => __( 'Add New Connector' ),
'edit' => __( 'Edit'),
'edit_item' => __( 'Edit Connector' ),
'new_item' => __( 'New Connector'),
'view' => __( 'View Connector'),
'view_item' => __( 'View Connector'),
'search_items' => __( 'Search Connectors'),
'not_found' => __( 'No Connectors found' ),
'not_found_in_trash' => __( 'No Connectors found in trash' ),
'parent' => __( 'Parent Connector')
),
'description' => __( 'This is where you can add new Connectors' ),
'public' => true,
'show_ui' => true,
'capability_type' => 'page',
'publicly_queryable' => true,
'exclude_from_search' => false,
'hierarchical' => true,
'rewrite' => array( 'slug' => 'connector', 'with_front' => false ),
'query_var' => true,
'supports' => array( 'title', 'editor', 'thumbnail', 'comments', 'excerpt','author',/*, 'page-attributes'*/ ),
'taxonomies' => array('post_tag'), // this is IMPORTANT for adding tags
'has_archive' => true,
'show_in_nav_menus' => true,
'show_in_menu'=>false
)
);
and then further used into my website and having large number of authors.
Now, I want to add custom capabilities to my custom post type - 'connector'. I have followed answer from Change custom post type to hierarchical after being registered
function modify_connectors() {
if ( post_type_exists( 'connector' ) ) {
$capabilities = array(
'publish_posts' => 'publish_connectors',
'edit_posts' => 'edit_connectors',
'edit_others_posts' => 'edit_others_connectors',
'delete_posts' => 'delete_connectors',
'delete_others_posts' => 'delete_others_connectors',
'read_private_posts' => 'read_private_connectors',
'edit_post' => 'edit_connector',
'delete_post' => 'delete_connector',
'read_post' => 'read_connector',
);
global $wp_post_types, $wp_rewrite;
$wp_post_types['connector']->hierarchical = true;
$wp_post_types['connector']->capability_type = 'connector';
$wp_post_types['connector']->capabilities = $capabilities;
//I am not sure from nowonwards am I doing right or wrong
$args = $wp_post_types['connector'];
$wp_rewrite->add_rewrite_tag("%connector%", '(.+?)', $args->query_var ? "{$args->query_var}=" : "post_type=connector&name=");
add_post_type_support('connector','page-attributes');
}
}
add_action( 'init', 'modify_connectors', 1 );
I can't find any custom capabilities under "User Role Editor" menu related to connector. Is this something possible to add custom capabilities after register post type has been completed?