How to Disable the WordPress Admin Bar

Want to hide or disable the admin bar in your WordPress website?

The WordPress admin bar (also called a toolbar) contains handy shortcuts to pages like Dashboard, Edit Post, New Page, Themes, Menus, Widgets, Customize, etc.

You may want to remove the admin bar for subscribers and contributors who don’t need access to the backend of your site. Developers working on the site may want to get rid of the admin bar as it tends to throw off the design of the front-end. Some people may even find the admin bar distracting.

Whatever the case, removing the admin bar is super easy. In this article, we will show how to disable it from your WordPress website. Let’s dive right in.

How to Disable Admin Bar in WordPress

There are three ways to disable the admin bar. Those are:

  1. Disable the WordPress admin bar from the dashboard
  2. Disable the admin bar using a plugin
  3. Disable the admin bar in WordPress manually by adding a code snippet

Whether you disable the admin bar with a plugin or do it manually, we will show you the exact steps that you need to take.

But before we go on, we strongly recommend that you take a backup of your entire website. To disable the admin bar, you will need to install a plugin or manually add a code snippet. And in our personal experience, adding code snippets or installing a new plugin can break your website. So please take a backup before you proceed with any of the steps below.

1. Disable Admin Bar From WordPress Dashboard

You can disable the admin bar from the WordPress dashboard by going to Users > All Users.

Open the profile of the user for whom you want to disable the admin bar.

On the user profile page, you should see an option called Show Toolbar When Viewing Site. Uncheck the option, and the toolbar will be disabled for that user.

As you can see, this method can disable only one user at a time. For websites with a lot of users, you would need an option that will enable you to disable an admin bar in bulk. Unfortunately, WordPress offers no such option on your dashboard, so you have to rely on a third-party plugin.

2. Disable Admin Bar Using a WordPress Plugin

To disable the admin bar using a plugin, install and activate the ProfilePress plugin.

Next, go to Settings > Admin Bar & Dashboard Access and select Check to Disable Admin Bar.

And that’s it! You have disabled the admin bar for all your WordPress site users except for administrators.

Disable WordPress admin bar for all users

If you want to disable the admin bar for only contributors and subscribers, you can do that. The plugin allows you to disable the admin bar based on user roles.

Just go to the plugin’s settings page and select Contributors and Subscribers.

It’s worth mentioning that, with ProfilePress, you can also restrict access to the WordPress Dashboard.

Even after you disable the admin bar, some users will try to access the backend of the site. To ensure that certain users can’t access the dashboard, you can simply go to Settings > Admin Bar & Dashboard Access and select Contributors or Subscribers or whichever user roles you want to restrict. Then save the settings.

While plugins are the easiest way to disable the toolbar, some of you might not want to add yet another plugin to your website. After all, too many plugins can make your website super slow.

In such a case, you can disable the admin bar by manually adding a code snippet.

2. Disable Admin Bar Manually By Adding a Code Snippet

It’s worth noting that the manual method involves inserting a code into your website’s theme. Any changes to make to the theme are lost when theme developers update the theme. To prevent losing customization, people use a child theme. For a layperson, creating a child theme is difficult. So we recommend using the plugin method unless you are a developer and you are comfortable making changes to the theme’s code.

To disable the admin bar manually for all users, you will need to go to Appearance > Theme Editor > function.php. Scroll to the end of the page and add the following code:

/* Disable WordPress Admin Bar for all users */

add_filter( 'show_admin_bar', '__return_false' );

Save the setting and check your website. The toolbar should be disabled for all users.

NOTE: If adding a code snippet to your theme is too daunting, then try adding a CSS code to your website. It’s super easy. Go to Appearance > Customize > Additional CSS and add this CSS code:

#wpadminbar { display:none !important;}

Many of you probably don’t want to disable the admin for all users. So we will show you how to manually disable the admin bar based on user role.

Go to Appearance > Theme Editor > function.php and add the following code snippet at the end of the page:

function tf_check_user_role($roles)
{
    /*@ Check user logged-in */

    if (is_user_logged_in()) :

        /*@ Get current logged-in user data */

        $user = wp_get_current_user();

        /*@ Fetch only roles */

        $currentUserRoles = $user->roles;

        /*@ Intersect both array to check any matching value */

        $isMatching = array_intersect($currentUserRoles, $roles);

        $response = false;

        /*@ If any role matched then return true */

        if ( ! empty($isMatching)) :

            $response = true;

        endif;

        return $response;

    endif;

}

$roles = ['customer', 'subscriber'];

if (tf_check_user_role($roles)) {

    add_filter('show_admin_bar', '__return_false');

}

Remember to hit Update File. You can use this to disable the toolbar for contributors and subscribers. If you want to restrict any other user roles, simply add the roles to the code snippet.

Now, if you want to disable the user role for users except Administrators, then add the following code snippet to your function.php file:

add_action('after_setup_theme', 'remove_admin_bar');

function remove_admin_bar()
{
    if ( ! current_user_can('administrator') && ! is_admin()) {
        show_admin_bar(false);

    }
}

Hit Update File.

 

That’s it, folk. You now know how to disable the admin bar on your WordPress website.

Conclusion

We hope you have learned how to hide and disable the WordPress admin bar on your website.

The admin bar is meant to be a useful tool, but if you want to prevent certain users from poking about in your admin dashboard, disabling it makes sense. Using the ProfilePress plugin is the easiest way to disable the admin bar for a large number of users.

That said, ProfilePress is more than just an admin bar restriction tool. It’s a powerful plugin designed to build user profiles and member directories, among other things. Here’s a complete overview of all the things that you can do with this plugin.

Give ProfilePress a try!

Create Paid Membership Websites in Minutes

Install ProfilePress today and get a modern and powerful WordPress membership & ecommerce website – the easy way!