How to Hide the WordPress Admin Bar Using a Plugin or Code

When accessing a WordPress website, logged-in users should see a black bar on top of the page. Known as the WordPress admin bar, it serves as a quick-access shortcut containing various options.

While the WordPress admin bar is a useful tool, many web developers hide it to preserve the site design. Some may also disable it to prevent other users from accessing the WordPress dashboard.

This article will extend your knowledge of WordPress even further by explaining different methods to hide your admin bar.

To hide the WordPress admin bar, you can add a code snippet to your functions.php file or install a plugin that allows you to disable it. To remove it for specific user roles, you can use a plugin or edit the code snippet accordingly.

How to Hide the Admin Bar for All Users

It’s possible to disable the admin bar using a plugin or by editing the site’s code. Remember, this method will disable the WordPress admin bar for all users at once.

Important! Before making any changes, back up your WordPress website. If you encounter an error, restore a previous site version using the backup file.

Using a Plugin

There are various plugins for this purpose, such as Hide Admin Bar. They offer a visual interface, ideal if you are unfamiliar with programming language.

They are also easy to set up and disable if necessary. For this tutorial, we will use Hide Admin Bar as it is the most popular option.

Once activated, this WordPress plugin will automatically disable the admin bar:

  1. Open your WordPress admin page. From the sidebar, go to → PluginsAdd New
  2. Enter the plugin’s name on the search bar and hit Enter.
  3. Click Install. After the installation finishes, select Activate.
Hide Admin Bar plugin in the WordPress Add Plugins menu

Instead of disabling the top admin bar, you can hide it using a WordPress plugin like Auto Hide Admin Bar.

The toolbar will only appear when you hover the cursor over the top area of the website.

Using Code

If you have too many plugins, remove the admin bar manually by editing the site’s code. You can do it multiple ways – by editing your WordPress theme file or adding custom CSS code.

Here are the steps to hide the toolbar by editing your website theme’s .php file:

  1. Log in to your WordPress admin page.
  2. From the WordPress menu, go to → AppearanceTheme File Editor.
Theme File Editor menu on WordPress sidebar
  1. Find the Theme Files on the right side of your screen and click functions.php.
  2. Scroll down to the end of the page and paste the following snippet:
add_filter('show_admin_bar', '__return_false');
  1. Click the Update File button to save the changes.
Theme File Editor menu on WordPress sidebar

Important! If the Theme file editor menu is unavailable in the Appearance section, it may be under the Tools category.

Alternatively, remove the admin bar by writing additional CSS:

  1. From the WordPress sidebar, select → AppearanceCustomize. If you can’t find this menu, open the customizer by visiting sitename.tld/wp-admin/customize.php on your web browser.
  2. On the left sidebar, select Additional CSS.
Additional CSS menu on WordPress theme customizer
  1. Enter the following code:
 #wpadminbar {display:none !important;}
  1. Click the Publish button.

How to Hide the Admin Bar for a Specific User

If you don’t want to hide the admin toolbar from everyone, disable it for a specific user. This method helps prevent other users from accessing your site’s WordPress dashboard.

Hide the admin bar for one particular user by editing their profile via the WordPress admin dashboard:

  1. Login to the WordPress dashboard, navigate to the sidebar UsersAll users.
The display all users menu on the WordPress sidebar
  1. Find the desired user. Hover over the user profile and click Edit underneath their name.
  2. Under the Personal Options section, find the Toolbar option and uncheck the Show Toolbar when viewing site box.
WordPress user settings: show toolbar when viewing site option
  1. Scroll down the page and click Update Profile to confirm.

The user will still see the toolbar inside the WordPress admin area. However, they won’t see it when visiting the website’s front end.

How to Hide the Admin Bar for Specific User Roles

It’s also possible to hide the admin bar manually for multiple WordPress users. However, it is tedious and time-consuming, especially if there are many.

To easily disable the admin toolbar for multiple users, assign them to the same role. Then, use a plugin or code to hide the admin bar for that user role.

Using a Plugin

Some WordPress plugins let you hide the toolbar for certain user roles. However, you need to assign the users to the same role first:

  1. From the WordPress sidebar UsersAll users.
  2. Locate the user and select Edit.
The edit button on the WordPress Users menu
  1. Under the Name section, assign a Role from the drop-down menu.
User role options
  1. Click Update User.

To change multiple users’ roles at once, follow these steps:

  1. Click the box next to their profile picture.
Bulk edit user settings on WordPress
  1. Choose a role from the Change role to… drop-down menu and click Change.

Now, download and install a plugin to hide the admin toolbar. In this tutorial, we will use Hide Admin Bar Based on Roles.

It lets you hide the admin toolbar for specific WordPress user roles and permissions. Here are the steps to hide the WordPress admin bar using this plugin:

  1. From the sidebar, navigate to SettingsHide Admin Bar Settings.
  2. Check the boxes next to the user roles from which you want to hide the toolbar.
Plugin settings: hide admin bar based on user roles
  1. Optionally, fill in the Capabilities Blacklist dialog box. Separate multiple capabilities by pressing Enter.
  2. Click Save Changes.

Using Code

Disable the admin bar for specific roles by adding a code snippet to the functions.php file of your WordPress site. You’ll need to use a different code depending on the roles and purposes.

For instance, to hide the admin bar for all users except those with administrative privileges:

  1. On the WordPress sidebar → AppearanceTheme File Editor.
  2. Go to the Theme Files sidebar and click functions.php.
  3. Scroll to the bottom of the screen and paste the following:
add_action('after_setup_theme', 'remove_admin_bar');
function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}

Whenever a user visits your site, this code checks if they have an administrator role. If they don’t, it will automatically hide the toolbar.

If you want to show the toolbar for the administrator and specific user roles, use the following instead:

function hide_wordpress_admin_bar($hide){
if (!current_user_can('administrator') || !current_user_can('subscriber')) {
return false;
}
return $hide;
}
add_filter( 'show_admin_bar','hide_wordpress_admin_bar');

The command above will hide the toolbar from all users except those with an administrator or subscriber role.

You may change or add more options by entering !current_user_can('role'), replacing “role” with the correspondent value.

Conclusion

The WordPress admin bar is a quick-access toolbar with various function shortcuts. Even though it’s a useful feature, some web developers prefer it hidden due to site visibility and security concerns.

Popular methods to hide the WordPress admin bar for all or specific users include:

  • Using the WordPress admin dashboard
  • With a plugin, such as Hide Admin Bar or Admin Bar Disabler
  • Adding code to your site’s functions.php or CSS file

We hope this article helped you find a suitable method. If you have questions about hiding the WordPress admin bar, leave them in the comments section below.

Author
The author

Aris Sentika

Aris is a Content Writer specializing in Linux and WordPress development. He has a passion for networking, front-end web development, and server administration. By combining his IT and writing experience, Aris creates content that helps people easily understand complex technical topics to start their online journey. Follow him on LinkedIn.