WordPress admin menu items access is restricted by special permissions or so-called capabilities. When you build new WordPress user role, it’s useful to know what menu item is restricted by what capability. It is necessary knowledge to add/remove admin submenus from user role via adding/removing correspondent capability.
If you have some PHP knowledge and you are curious enough, you will find the most part of WordPress admin menu definition, including its capabilities, at WordPress core source code. But what to do, if you are not PHP developer? Even me caught myself that it is too tedious open wp-admin/menu.php
file and find right piece of code every time in order to get needed capability name for the admin menu item to use it in own plugin or answer on plugin’s user or site visitor questions. Why do not document this? That’s the reason of this post was written. I hope it will be useful not for me only.
Look at the table below for the list of WordPress 3.3 admin menu items capabilities. Use “Index” and “Script” columns for more advance technique in order hide/block not needed menu items.
Submenu | Menu Item | Capability | Index | Script |
---|---|---|---|---|
Dashboard | read | 2 | index.php | |
Home | read | [‘index.php’][0] | index.php | |
My Sites | read | [‘index.php’][5] | my-sites.php | |
Updates | update_core | [‘index.php’][10] | update-core.php | |
Posts | edit_posts | 5 | edit.php | |
All Posts | edit_posts | [‘edit.php’][5] | edit.php | |
Add New | edit_posts | [‘edit.php’][10] | post-new.php | |
Categories | manage_categories | [‘edit.php’][15] | edit-tags.php?taxonomy=category | |
Tags | manage_categories | [‘edit.php’][16] | edit-tags.php?taxonomy=post_tag | |
Media | upload_files | 10 | upload.php | |
Library | upload_files | [‘upload.php’][5] | upload.php | |
Add New | upload_files | [‘upload.php’][10] | upload.php | |
Links | manage_links | 15 | link-manager.php | |
All Links | manage_links | [‘link-manager.php’][5] | link-manager.php | |
Add New | manage_links | [‘link-manager.php’][10] | link-add.php | |
Link Categories | manage_categories | [‘link-manager.php’][15] | edit-tags.php?taxonomy=link_category | |
Pages | edit_pages | 20 | edit.php?post_type=page | |
All Pages | edit_pages | [‘edit.php?post_type=page’][5] | edit.php?post_type=page | |
Add New | edit_pages | [‘edit.php?post_type=page’][10] | post-new.php?post_type=page | |
Comments | edit_posts | 25 | edit-comments.php | |
Appearance |
switch_themes edit_theme_options |
60 | themes.php | |
Themes |
switch_themes edit_theme_options |
[‘themes.php’][5] | themes.php | |
Customize | edit_theme_options | [‘themes.php’][6] | customize.php | |
Widgets | edit_theme_options | [‘themes.php’][7] | widgets.php | |
Menus | edit_theme_options | [‘themes.php’][10] | nav-menus.php | |
Header | edit_theme_options | [‘themes.php’][11] | custom-header | |
Background | edit_theme_options | [‘themes.php’][12] | custom-background | |
Editor | edit_themes | last | theme-editor.php | |
Plugins | activate_plugins | 65 | plugins.php | |
Installed Plugins | activate_plugins | [‘plugins.php’][5] | plugins.php | |
Add New | install_plugins | [‘plugins.php’][10] | plugin-install.php | |
Editor | edit_plugins | [‘plugins.php’][15] | plugin-editor.php | |
Users | list_users | 70 | users.php | |
All Users | list_users | [‘users.php’][5] | users.php | |
Add New |
create_users or promote_users |
[‘users.php’][10] | user-new.php | |
Your Profile | read | [‘users.php’][15] | profile.php | |
Profile | read | 70 | profile.php | |
Your Profile | read | [‘profile.php’][5] | profile.php | |
Add New |
create_users or promote_users |
[‘profile.php’][10] | user-new.php | |
Tools | edit_posts | 75 | tools.php | |
Available Tools | edit_posts | [‘tools.php’][5] | tools.php | |
Import | import | [‘tools.php’][10] | import.php | |
Export | export | [‘tools.php’][15] | export.php | |
Delete Site | manage_options | [‘tools.php’][25] | ms-delete-site.php | |
Settings | manage_options | 80 | options-general.php | |
General | manage_options | [‘options-general.php’][10] | options-general.php | |
Writing | manage_options | [‘options-general.php’][15] | options-writing.php | |
Reading | manage_options | [‘options-general.php’][20] | options-reading.php | |
Discussion | manage_options | [‘options-general.php’][25] | options-discussion.php | |
Media | manage_options | [‘options-general.php’][30] | options-media.php | |
Privacy | manage_options | [‘options-general.php’][35] | options-privacy.php | |
Permalinks | manage_options | [‘options-general.php’][40] | options-permalinks.php |
Top level menu items data are stored in the $menu
array. Use $menu[index_value]
to access it from PHP code.
Submenus data are stored in the $submenu
array. Use $submenu[script_name][index_value]
to access it from PHP code.
Do not forget to declare global $menu, $submenu;
before that.
Tags: WordPress