Add-action in function
You can simply remove those menu items in your check_username method. add_action(‘admin_init’, ‘check_username’); function check_username() { $user = wp_get_current_user(); if( $user && isset($user->user_email) && ‘[email protected]’ == $user->user_email ) { remove_menu_page(‘tools.php’); remove_menu_page(‘themes.php’); remove_menu_page(‘options-general.php’); remove_menu_page(‘plugins.php’); } } Your code doesn’t work, because the admin_init action is invoked after admin_menu. Please see the Action reference page in WordPress … Read more