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 explain different methods to hide your WordPress site admin bar for all and specific users.
Important! Before making any changes, back up your WordPress website. If you encounter an error, restore a previous site version using the backup file.
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.
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:
- Open your WordPress admin page. From the sidebar, go to → Plugins → Add New
- Enter the plugin’s name on the search bar and hit Enter.
- Click Install. After the installation finishes, select Activate.
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:
- Log in to your WordPress admin page.
- From the WordPress menu, go to → Appearance → Theme File Editor.
- Find the Theme Files on the right side of your screen and click functions.php.
- Scroll down to the end of the page and paste the following snippet:
add_filter('show_admin_bar', '__return_false');
- Click the Update File button to save the changes.
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:
- From the WordPress sidebar, select → Appearance → Customize. If you can’t find this menu, open the customizer by visiting sitename.tld/wp-admin/customize.php on your web browser.
- On the left sidebar, select Additional CSS.
- Enter the following code:
#wpadminbar {display:none !important;}
- 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:
- On the WordPress dashboard, navigate to the sidebar → Users → All users.
- Find the desired user. Hover over the user profile and click Edit underneath their name.
- Under the Personal Options section, find the Toolbar option and uncheck the Show Toolbar when viewing site box.
- 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:
- From the WordPress sidebar → Users → All users.
- Locate the user and select Edit.
- Under the Name section, assign a Role from the drop-down menu.
- Click Update User.
To change multiple users’ roles at once, follow these steps:
- Click the box next to their profile picture.
- 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:
- From the sidebar, navigate to Settings → Hide Admin Bar Settings.
- Check the boxes next to the user roles from which you want to hide the toolbar.
- Optionally, fill in the Capabilities Blacklist dialog box. Separate multiple capabilities by pressing Enter.
- 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:
- On the WordPress sidebar → Appearance → Theme File Editor.
- Go to the Theme Files sidebar and click functions.php.
- 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.