WordPress

How to Disable WordPress Admin Bar for All Users Except Administrators

By default whenever you are logged into your WordPress site you will see a little toolbar at the top of the site with some quick links to different admin sections as well as the ability to log out of the site when wanted. While this toolbar can be useful for going back and forth from the WordPress backend and the live site, it actually can slow things down quite a bit and we usually recommend disabling it (also it can be annoying when you want to look at your beautiful site and there is an ugly black bar at the top).

Option 1: Disabling the toolbar via your user settings

The quickest and easiest way to disable the toolbar is to head over to log into WordPress and head over to Users > Your Profile > Show Admin Bar. Here you can uncheck the option so it won’t show up “when viewing site” (see image below).

Option 2: Disable Admin Bar for All Users Except for Administrator

The last option is to disable the admin bar using some code either in your child theme’s functions.php file, in your custom theme or a snippets plugin. Below are 2 examples showing how to disable it either for everyone or conditionally:

add_action('after_setup_theme', 'remove_admin_bar');
 
function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
  show_admin_bar(false);
}
}

Options 3: Disable Admin Bar for All Users

If you want to disable it for all users, then simply put use this code in your theme’s functions.php file or your site-specific plugin.

/* Disable WordPress Admin Bar for all users but admins. */
  show_admin_bar(false);