我正在创建新的用户角色“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,
)
);
Run Code Online (Sandbox Code Playgroud)
那么如何在wordpress仪表板中仅显示自定义插件菜单
小智 5
向您的插件菜单添加自定义功能
$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' => false,
'custom_capability_name'=>true,
)
);
Run Code Online (Sandbox Code Playgroud)
在那之后添加
$role= get_role('test_client');
$role->add_cap('custom_capability_name');
Run Code Online (Sandbox Code Playgroud)
最后将您的管理菜单“manage_option”更改为您的“cusotom_capability_name”
| 归档时间: |
|
| 查看次数: |
3219 次 |
| 最近记录: |