Hide Admin Menus

Sometimes it helps your client to have WordPress Admin items unavailable. You can provide this customization easily using the following WordPress code snippet.

Hiding WordPress Admin menu items isn’t something I would do without client consent. The last thing you want to do is leave them wondering where important site controls and menus have gone.

But in some instances it can be helpful. Include the following code snippet in your WordPress functions.php file. Comment out the lines for the items you don’t want hidden.

/**
* 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' ); 

Hire a WordPress Expert

Get hourly and project based theme customization, theme tweaks, and development help from world-class WordPress developers at Codeable. If you’re in Kelowna and need a custom website for your business visit our Kelowna Web Design page now to get started.