Who can help me with roles and capabilities? I am stuck on this and I need some help.
I want a role that only can add, remove edit etc. a specific CPT.
What I have so far
add_action('init', function(){
register_post_type( 'catalog',
array(
'capability_type' => 'manage_catalog',
'labels' => array(
'name' => 'Catalogus',
'add_new' => 'Nieuw item',
'add_new_item' => 'Nieuw item toevoegen',
'new_item' => 'Nieuw item',
),
'public' => true,
'query_var' => true,
'show_ui' => true,
'show_in_rest' => false,
'menu_icon' => 'dashicons-store',
'menu_position' => 2,
'supports' => array(
'title',
'thumbnail',
),
)
);
add_action('load-themes.php', function(){
global $pagenow;
if('themes.php' == $pagenow && isset($_GET['activated'])){
$role = get_role('subscriber');
$role->add_cap('manage_catalog');
}else{
//Remove the capacity when theme is deactivate
$role = get_role('subscriber');
$role->remove_cap('manage_catalog');
}
});
With the code above I can not see the CPT catalog in the menu on the admin side. What I am missing in my code?