add_action(\'admin_menu\', \'remove_admin_menu_links\');
function remove_admin_menu_links(){
$user = wp_get_current_user();
if( $user && isset($user->user_email) && \'[email protected]\' == $user->user_email ) {
remove_menu_page(\'upload.php\'); // Media - works(remove)
remove_menu_page( \'gf_edit_forms\' ); //Forms - doesn\'t work(visibile)
remove_menu_page(\'edit.php?post_type=page\'); // Pages - works(removed)
remove_menu_page(\'wpseo_dashboard\'); // SEO - works(remove)
remove_menu_page(\'admin.php?page=wpseo_dashboard\'); // SEO - works(remove)
remove_menu_page(\'envanto-market\'); // Envanto Market - doesn\'t work(visibile)
remove_menu_page(\'admin.php?page=envanto-market\'); // Envanto Market - doesn\'t work(visibile)
remove_menu_page(\'gadwp_settings\'); // Google Analytics - doesn\'t work(visibile)
remove_menu_page(\'admin.php?page=gadwp_settings\'); // Google Analytics - doesn\'t work(visibile)
}
}
add_action( \'admin_menu\', \'remove_admin_menus_links\' , 9999 );
上面概述的显示了为从特定管理员用户菜单项中删除菜单项而添加的操作。
我似乎无法删除表单、Envanto Market或Google Analytics。其余的菜单项都被删除了,但我不明白为什么这几个菜单项看起来没有移动。
如果有人知道为什么这些菜单项仍然可用?
此外,页面顶部的admin\\u bar\\u菜单和new\\u Post选项中还有这些菜单项的完整列表。如果有人能给我指出正确的方向,让我也移除这些?
我尝试添加到functions.php:
// admin_bar_menu hook
add_action(\'admin_bar_menu\', \'update_adminbar\', 999);
在
/plugins/admin_bar.php :
<?php
// update toolbar
function update_adminbar($wp_adminbar) {
// remove unnecessary items
$wp_adminbar->remove_node(\'wp-logo\');
$wp_adminbar->remove_node(\'customize\');
$wp_adminbar->remove_node(\'comments\');
$wp_adminbar->remove_node(\'post-new\');
}
?>