我正在创建新的用户角色“test_client”并且它正在工作但我的问题是我只想在仪表板中显示我的自定义插件页面菜单但是在此代码中“manage_options”是'true'然后所有插件菜单显示,如果“ manage_options“是'false'没有显示任何插件菜单..
$result = add_role('test_client', 'Test_client',
array(
// Dashboard
'read' => true, // true allows this capability
'edit_posts' => true, // Allows user to edit their own posts
'edit_pages' => true, // Allows user to edit pages
'edit_others_posts' => false, // Allows user to edit others posts not just their own
'create_posts' => false, // Allows user to create new posts
'manage_categories' => false, // Allows user to manage post categories
'publish_posts' => false, // Allows the user to publish, otherwise posts stays in draft mode
'manage_options' => true,
)
);
所以如何在wordpress仪表板中只显示自定义插件菜单
答案 0 :(得分:4)
为您的插件菜单添加自定义功能
$result = add_role('test_client', 'Test_client',
array(
// Dashboard
'read' => true, // true allows this capability
'edit_posts' => true, // Allows user to edit their own posts
'edit_pages' => true, // Allows user to edit pages
'edit_others_posts' => false, // Allows user to edit others posts not just their own
'create_posts' => false, // Allows user to create new posts
'manage_categories' => false, // Allows user to manage post categories
'publish_posts' => false, // Allows the user to publish, otherwise posts stays in draft mode
'manage_options' => fasle,
'cusotom_capability_name'=>true,
)
);
之后添加
$role= get_role('test_client');
$role->add_cap('cusotom_capability_name');
最后更改您的管理菜单' manage_option'到你的&cusotom_capability_name'