将自定义页面添加到仅对编辑者用户可见的管理菜单 [英] Add custom page to admin menu visible only to editor users
问题描述
我想建立一个自定义分配管理并将其结果显示在wordpress后端。
I want to build a custom assign management and display its results in the wordpress backend.
我添加了一个新的管理菜单项,如下所示:
I added a new admin menu item like this:
add_action('admin_menu', 'register_custom_menu_page');
function register_custom_menu_page()
{
add_menu_page('Approval', 'Approval Management','add_users', 'manage_approval.php', '','images/check.gif',86);
}
这在管理员登录中工作正常,但我需要这样做在编辑器登录时显示。
this is working fine with admin login but i need this to show when editor gets logged in.
请让我知道正确的解决方案。
谢谢
Please let me know the correct solution. Thanks
推荐答案
add_menu_page() 函数是 $ capabilities
,表示:
向用户显示此菜单所需的功能。
在您的情况下,您设置了'add_users'
,这是一种功能,只有 admin 用户具有的权限,因此它只会显示给管理员。
In your case you set 'add_users'
, which is a capability that only the admin users have, so it will be only displayed to administrators.
您只需将其更改为编辑者具有的其他功能,例如 edit_pages
。
You just need to change it to other capability that editors have, for example 'edit_pages'
.
请注意,这对于编辑者和管理员都是可见的,因为他们也有 >功能。
Note that this will make it visible for editors and also for admins, since they also have that capability.
请参阅 WordPress角色&功能 以获取更多信息。
See the complete list of WordPress Roles & Capabilities for further info.
这篇关于将自定义页面添加到仅对编辑者用户可见的管理菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!