Add custom page to admin menu visible only to editor users

点点圈 提交于 2019-12-08 06:08:56

问题


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


回答1:


The third parameter of the add_menu_page() function is $capabilities, which represents:

"The capability required for this menu to be displayed to the user."

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.

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.

See the complete list of WordPress Roles & Capabilities for further info.



来源:https://stackoverflow.com/questions/22768664/add-custom-page-to-admin-menu-visible-only-to-editor-users

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!