How to Hide WordPress Admin Bar for All Users Except Admin

Are you looking for a simple way to hide the WordPress admin bar?

You may easily disable the WordPress admin bar for any user from the dashboard by default. However, if your site has many registered users, this approach may take some time.

We’ll show you how to hide the WordPress admin bar for all users except administrators in this post.

What is WordPress Admin Bar?

WordPress shows an admin bar on the top for all logged-in users by default. This toolbar appears on all pages, including the WordPress admin area when you’re logged in.

The WordPress admin toolbar provides useful shortcuts to different WordPress sections. The shortcuts present in the admin bar change depending on a users’ role and permissions in WordPress.

However, while browsing the public pages on the front end of your website, the admin bar might be distracting. It may also impact the design and user experience of your website.

However, there are several ways to hide the WordPress admin bar for all users other than admin.

Method 1: Hide WordPress Admin Bar for a Specific User

You can hide the admin bar for selected users from the WordPress dashboard.

Go to the Users » All Users page and click on the Edit link for any user you want to disable the admin bar.

This will bring you to the user profile editor page. Uncheck the box next to the Show toolbar when viewing the site option.

WordPress Show Toolbar Option

Scroll down and click the Update User button to save your changes.

This will hide the admin bar for that particular user when they visit the website.

Method 2: Disable Admin Bar for All Users Except Admins with a Plugin

This method allows you to disable the WordPress admin for all users quickly.

First, you need to Install and Activate the Hide Admin Bar Based on User Roles plugin. For more in detail, see our guide on how to install a plugin in WordPress.

Hide Admin Bar Based on User Roles WordPress Plugin

Upon activation, go to the Settings » Hide Admin Bar Settings page. Select the user roles you want to prevent from accessing the WordPress dashboard and Save your settings.

Hide Admin Bar Based on User Roles Settings

Method 3: Disable Admin Bar for All Users Except Admin Using Code

Installing and managing new plugins may be a headache. If you don’t like installing new plugins on your WordPress site, we suggest using the manual method of adding a code snippet to hide the WordPress admin bar.

Add the following code snippet to your theme’s functions.php file or a site-specific plugin.

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

This code checks whether or not the current user is an administrator and is not viewing the admin dashboard. If both requirements are met, the WordPress admin bar is disabled.

Remember to save your changes and verify your website to ensure that everything is working correctly.

Method 4: Hide Admin Bar for All Users Including Admins

You can hide the admin bar for all users, including the admin, by modifying the earlier code.

Copy and paste the below code snippet to your theme’s functions.php file or a site-specific plugin.

add_filter( 'show_admin_bar', '__return_false' );

This code will hide the admin bar for all users when viewing your website’s public pages. All users will still see the toolbar inside the WordPress admin dashboard.

We hope this post helps you learn how to disable the WordPress admin bar for all users except administrators. If you like this post, you might be also want to read: