How to Hide WordPress Admin Bar in Every Way

You are currently viewing How to Hide WordPress Admin Bar in Every Way

The WordPress admin bar is displayed for logged-in users at the top of the page and contains helpful links for various tasks.

While the admin bar can be handy to the administrator of the website, it isn’t beneficial for many other users, especially regular website subscribers. Therefore, you should hide it.

In this article, I will show you how to hide the admin bar in WordPress for a specific user, everyone, or everyone except the administrator.

Hide Admin Bar for a Specific User

If you want to disable the admin bar for a specific user only, it is straightforward and does not require any plugin or function.

First, navigate to the Users page and click Edit on the desired user.

Hide admin bar from a specific user

Inside the edit user screen, uncheck the ‘show Toolbar when viewing site’ box and click update profile.

Uncheck the toolbar option

Once saving the changes, this specific user will no longer see the admin bar.

There aren’t many reasons to disable the toolbar for only one user. You may want to hide it instead for everyone or show it only to users of a specific role.

We can do that using a WordPress function or a plugin. I will show you both options. Let’s start by adding a function to hide the admin bar.

Hide the Admin Bar Using a Function

The functions below will show you how to disable the bar for all users but the administrator.

Make sure to paste these functions into the functions.php file of your child’s theme.

Please make sure to backup your website before editing core files.

To access the functions file, navigate to Appearance -> Theme Editor and look for the functions.php file from the list on the right.

Then, scroll to the bottom of the file and paste your chosen desired function from below.

Paste the function in the functions php file copy

Hide the admin bar to all users

To remove the admin bar for all users, use this function:

show_admin_bar(false);

Disable the admin bar to all user roles except administrators

To hide the admin bar for all users besides the administrator role, use this function:

// Hide admin bar from subscribers
add_action('after_setup_theme', 'pfwp_remove_admin_bar');
function pfwp_remove_admin_bar() {
  if ( !in_array( 'administrator', (array) wp_get_current_user()->roles ) ) {
    show_admin_bar(false);
  }
}

Make sure to click on the Save Changes button after pasting the functions.

However, if you don’t want to use functions and prefer a plugin, follow the section below.

Hide the Admin Bar Using a Plugin

The easiest way to hide the WordPress admin bar is by using a plugin.

Therefore, navigate to Plugins -> Add New and search for the Hide Admin Bar Based on User Roles plugin.

Click Install and then Activate on the first result on the left.

Hide admin bar based on user role plugin

Once activated, the plugin, navigate to Settings -> Hide Admin Bar Settings.

The hide admin bar for all users option will disable the admin bar for all users, including the administrator.

Hide admin bar for all users option

Alternatively, the hide admin bar for all guest users will disable the admin bar for all users with the subscriber role.

Hide admin bar for all guests users option

All the other users, including the administrator and the editor, will keep seeing the bar.

In the third option, you’ll be able to disable the admin bar for users based on their roles.

If, for example, you would like to hide the bar to all role users except the admin, author, editor, and contributor, make sure you check all boxes except theirs.

Hide admin bar based on user roles

Whatever you choose, don’t forget to scroll to the bottom of the page and click on the Save Changes button.

Auto-hide admin bar

Another great plugin to hide the WordPress admin bar is the auto hide admin bar.

This plugin is mainly directed at site administrators that would like to work on their website with a clean slate without seeing the admin bar in their view.

Once you activate the plugin, it will hide the admin bar while browsing the website’s frontend. That way, you’ll have a clear view of your website.

When you are ready to access the admin bar once again, hover your mouse over the top of the browser window to make it reappear.

Conclusion

In this article, you learned how to hide the WordPress admin bar in multiple ways.

Leave us a comment below and let us know which one of the methods you used to achieve this task.

Also, make sure to subscribe to our YouTube channel and like our page on Facebook.

PluginsForWP

PluginsForWP is a website specializing in redistributing WordPress plugins and themes with a variety of knowledge about WordPress, internet marketing, and blogging.

This Post Has 4 Comments

  1. Jim

    Thanks. How can you extend the code example to show the admin bar only for a list of roles, like administrator, editor, author? Or perhaps more simply, users with a certain capability, like ‘edit_posts’?

    1. PluginsForWP

      Hi, please try this:
      // Hide admin bar from subscribers
      add_action(‘after_setup_theme’, ‘pfwp_remove_admin_bar’);
      function pfwp_remove_admin_bar() {
      $display_bar = array(‘administrator’, ‘author’, ‘editor’);
      if( !array_intersect($display_bar, (array) wp_get_current_user()->roles ) ) {
      show_admin_bar(false);
      }
      }

  2. Jen Niles

    How to hide one item link in the top admin bar? I don’t want to hide the whole top admin bar but one link that appears in the top admin bar. Thanks!

    1. PluginsForWP

      You can do it with CSS. Which link would you like to hide? I can provide you with the code.

Leave a Reply