问题
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