Owning a website becoming expensive?

No more! In our library, you will find the best premium WordPress plugins and themes for a fraction of the cost of the original prices. Browse Our Library

How to Hide WordPress Admin Bar in Every Way

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 useful links for various purposes.

While the admin bar can be very useful to the administrator of the website, it isn’t very useful for many other users, especially regular website subscribers.

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

Hide Admin Bar for a Specific User

If you would like to disable the admin bar for a specific user only, it is very easy.

Navigate to the Users page and click Edit for 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

After saving the changes, this specific user will not see the admin bar again.

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 certain role.

We can do that by using a WordPress function or by using a plugin. I will show you both options. Let’s start by adding or editing functions that change the code.

Hide the Admin Bar Using a Function

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

Make sure to paste these functions in the functions.php file of your child theme.

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

Scroll to the bottom of the file and paste your chosen desired function from below.

Paste the function in the functions php file copy

Disable 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.

If you don’t like to use functions and would prefer using a plugin, follow the section below.

Hide the WordPress Admin Bar Using a Plugin

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

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

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

Hide admin bar based on user role plugin

After activating 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

The hide admin bar for all guest users option 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 to 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 chose, don’t forget to scroll to the bottom of the page and click on the Save Changes button.

Conclusion

The admin bar is unnecessary for regular WordPress subscribers’ roles and can be easily hidden using a function or a plugin.

Make sure to watch the video and leave us a comment below if you have any questions.

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

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on email

PluginsForWP

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

Leave a Reply