admin管理员组文章数量:1291032
I want to hide some menus on admin panel: Appearance, Plugins, and Tools.
How to hide it without plugin?
And how can I un-hide them later easily?
I want to hide some menus on admin panel: Appearance, Plugins, and Tools.
How to hide it without plugin?
And how can I un-hide them later easily?
Share Improve this question edited Feb 13, 2014 at 6:35 Mayeenul Islam 12.9k21 gold badges85 silver badges169 bronze badges asked Feb 13, 2014 at 5:43 Lena QueenLena Queen 1551 gold badge1 silver badge3 bronze badges 2- I don't quite understand your question about un-hiding it. By removing the functions in my answer below, they should reappear. – iyrin Commented Feb 13, 2014 at 6:33
- For all roles and capabilities? – Brad Dalton Commented Feb 13, 2014 at 10:58
3 Answers
Reset to default 6You can do this with remove_menu_page. Add the appropriate menu slug in your functions.php of your theme or your plugin.
<?php remove_menu_page( $menu_slug ) ?>
Note that users can still access these menus using a direct link. If you intend to block a user from accessing a menu, you will have to set up a user role and make sure they don't have the relevant capabilities.
Here is a list of slug examples for the menus included in a clean WordPress install.
<?php
function remove_menus(){
remove_menu_page( 'index.php' ); //Dashboard
remove_menu_page( 'edit.php' ); //Posts
remove_menu_page( 'upload.php' ); //Media
remove_menu_page( 'edit.php?post_type=page' ); //Pages
remove_menu_page( 'edit-comments.php' ); //Comments
remove_menu_page( 'themes.php' ); //Appearance
remove_menu_page( 'plugins.php' ); //Plugins
remove_menu_page( 'users.php' ); //Users
remove_menu_page( 'tools.php' ); //Tools
remove_menu_page( 'options-general.php' ); //Settings
}
add_action( 'admin_menu', 'remove_menus' );
?>
can do it with remove_menu_page()
try out these locations
Remove Menu Item in WordPress Admin Panel
Remove Unwanted Items from the WordPress Admin Sidebar
This is a nice chunk of code from Bill Erickson's Core Functionality plugin.
/**
* Remove Menu Items
* @since 1.0.0
*
* Remove unused menu items by adding them to the array.
* See the commented list of menu items for reference.
*
*/
function ni_remove_menus () {
global $menu;
// Example:
//$restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins'));
end ($menu);
while (prev($menu)){
$value = explode(' ',$menu[key($menu)][0]);
if(in_array($value[0] != NULL?$value[0]:"" , $restricted) {
unset($menu[key($menu)]);
}
}
}
add_action( 'admin_menu', 'ni_remove_menus' );
Uncomment the restricted array and include the menu items you'd like to hide. The example contains all the menu items for reference.
本文标签: How to hide menu on WordPress admin
版权声明:本文标题:How to hide menu on WordPress admin 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741506535a2382356.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论