谁可以在角色和能力方面帮助我?我被困在这个问题上,我需要一些帮助。
我想要一个角色,只能添加,删除编辑等一个特定的CPT。
到目前为止我拥有的
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\');
}
});
使用上面的代码,我无法在管理端的菜单中看到CPT目录。代码中缺少什么?