Hide Admin Menus

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* Hide Admin Menu Items from the admin menu for everyone but admin-user
*/
 
function remove_admin_menus()
{
    // provide a list of usernames who can edit custom field definitions here
    $admins = array( 
        'put admin user name here', 
    );
 
    // get the current user
    $current_user = wp_get_current_user();
 
    // match and remove if needed
    if( !in_array( $current_user->user_login, $admins ) )
    {
        remove_menu_page('edit.php?post_type=acf');     //Advanced Custom Fields	
        remove_menu_page( 'edit.php' );                 //Posts
    	remove_menu_page( 'edit-comments.php' );       //Comments
    	remove_menu_page( 'themes.php' );              //Appearance
    	remove_menu_page( 'tools.php' );               //Tools
    	remove_menu_page( 'options-general.php' );     //Settings
    	remove_menu_page( 'plugins.php' );             //Plugins
    	remove_menu_page('wpseo_dashboard');
    	remove_menu_page( 'index.php' );               //Dashboard
    	remove_menu_page( 'users.php' );               //Users
    }
 
}
 
add_action( 'admin_menu', 'remove_admin_menus', 999 );
 
//* Additional Function To Remove Genesis Menu link
//remove_theme_support( 'genesis-admin-menu' );