如果只想删除菜单选项,可以在函数中使用remove\\u menu\\u page函数。php文件
remove_menu_page
将此代码添加到函数。php:
function remove_menus(){
remove_menu_page( \'index.php\' ); //Dashboard
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\' );
这将删除除要保留的选项之外的所有内容。
如果只想删除编辑器的菜单选项,请在函数中使用If语句:
function remove_menus(){
if(current_user_can(\'editor\')){
remove_menu_page( \'index.php\' ); //Dashboard
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\' );