Add custom page to admin menu visible only to edit

2019-05-30 06:30发布

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条回答
【Aperson】
2楼-- · 2019-05-30 07:05

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.

查看更多
登录 后发表回答