How to hide the WordPress admin bar using a plugin, PHP code, and via the user settings

When logged-in users access a WordPress website, they can quickly access tools and shortcuts from the admin bar at the top. While useful, some developers might need to hide it for security reasons and visual improvements.

In this article, we will explain how to hide the WordPress admin bar for all users as well as specific roles only. We will also explore three methods with different difficulty levels so you can choose one based on your preferences.

How to hide the WordPress admin bar

Before proceeding, we recommend backing up your WordPress website so you can easily restore your data in case of errors.

1. Using a plugin

If you are unfamiliar with coding, using a WordPress plugin is the easiest way to hide the admin toolbar. This method is also convenient because you can easily revert the changes without altering your website code.

While you can use different WordPress plugins, we recommend Hide Admin Bar Based on User Roles. It offers various options to hide the toolbar and provides frequent updates to ensure security. Here’s how to use it:

  1. Log in to your WordPress dashboard and navigate to the sidebarPluginsAdd New Plugin.
  2. Search Hide Admin Bar Based on User Roles and click Install Now.
  1. Once the plugin installation process is complete, click Activate
  2. Head to the sidebarSettings Hide Admin Bar Settings
  3. Choose the user roles you want to hide the top admin bar from by clicking their respective boxes. Once finished, hit Save Changes

That’s it! If you want to show the admin bar again, return to the settings menu, untick the box, and save the changes.

Important! Update your plugin periodically to avoid security risks. For Hostinger managed WordPress hosting users, we recommend enabling the auto-update feature to simplify the task.

2. Using PHP code

Installing too many plugins might cause performance issues and security risks if you don’t audit them properly. In this case, you might want to hide the WordPress admin bar manually by adding custom PHP code to your WordPress theme file.

Pro Tip

If you are unfamiliar with PHP, we recommend testing the code snippets in a WordPress staging area to avoid breaking the live website.

Before doing so, create and activate a child theme to ensure your custom PHP remains after an update. Now, let’s proceed with the steps for hiding the admin bar:

  1. Open your WordPress admin area → sidebarToolsTheme File Editor.
  2. Head to the Theme Files side menu on the right. Select the functions.php file. 
  3. From the code editor screen, add the following snippet at the bottom of the file before the ?> closing tag:
add_filter('show_admin_bar', '__return_false');
  1. Click Update File

Note that the snippet above will hide the WordPress admin bar for all users, regardless of their roles.

If you want to hide the admin bar for a specific account role, use the following code instead. For example, we will disable the toolbar for those with the subscriber role:

if (current_user_can('subscriber')) {

    add_filter('show_admin_bar', '__return_false');

}

With this code, you can also hide the admin bar for all users except for a specific role. For instance, we will show the toolbar only for those with administrative privileges:

add_action('after_setup_theme', 'remove_admin_bar');

function remove_admin_bar() {

if (!current_user_can('administrator') && !is_admin()) {

show_admin_bar(false); }

}

To revert the changes, simply delete the code from the PHP file and save the changes.

3. Via user settings

As an administrator, you can easily disable the WordPress admin bar for specific users via the account settings menu. Here’s how to do so:

  1. Log in to the WordPress admin dashboardsidebarUsersAll Users.
  2. Hover over the account you want to hide the admin bar from and click Edit profile.
  3. Go to the Toolbar setting and untick the box. 
  1. Scroll down to the bottom and click Update User to save the changes.

Now, when the user logs in, they won’t see the admin bar. Remember that this method only hides the toolbar for a specific user, meaning you must repeat the steps to apply the changes to multiple accounts within the same role.

Also, you can only manage other users’ settings if you are logged in as an administrator. Otherwise, you must manually log in to that account and change its configuration.

Why should you hide the WordPress admin bar?

Developers opt to hide the WordPress admin bar for various reasons. Here are some common considerations why you might want to do so:

  • Security concerns. The WordPress admin bar provides shortcuts to various functions that can alter your website, including editing posts and accessing the dashboard. Hiding the toolbar limits potential entry points that unauthorized users might exploit. 
  • Visual enhancement. Users might find the WordPress admin bar ruining the web page’s appearance. Hiding it helps improve the website’s visuals and maintain consistency across all users. 
  • Functionality. For logged-in users, the top admin bar at the top of the web page might obstruct important parts of the website. For example, it might prevent them from accessing the search bar or navigation menu.
  • User control. Administrators might hide the WordPress admin bar to manage user roles and access permissions over the website. 

Conclusion

WordPress admin bar offers quick-access tools and shortcuts for various functions. However, developers might want to hide it due to potential security risks and visual obstructions.

In this article, we have explained multiple ways to temporarily remove the admin bar. Here’s the recap:

  • Using plugin. This method is ideal for beginners with minimal coding experience. Install plugins like Hide Admin Bar Based on Roles on WordPress and disable the toolbar via Settings.
  • Adding PHP code. Developers can hide the admin bar by adding PHP functions and filters to the functions.php file. You can apply the setting for specific user roles using the if statement. 
  • Via user settings. Admin users can hide the admin bar for a specific account by unchecking the Toolbar option in the settings menu. If you don’t have the privilege, you must log in to that particular account first.

We hope this article helped you choose a suitable method for hiding the WordPress admin bar on your website. If you have any questions, leave us a comment below!

Hide WordPress admin bar FAQ

What is the WordPress admin bar?

WordPress admin bar is a top menu that logged-in users see when accessing a website. It provides quick access to various tools and shortcuts, including redirecting you to the post editor or the WordPress admin dashboard. 

Do I need the WordPress admin bar?

It depends on your needs. If you want to quickly edit a post or access tools without opening the WordPress dashboard, then you need the toolbar. However, if you are concerned about security and visibility issues, we recommend hiding it.

Will hiding the admin bar affect my WordPress site?

Hiding the admin bar won’t affect other aspects of your WordPress site. You can also easily revert the changes by uninstalling the plugin or deleting the PHP code. However, we always recommend backing up your WordPress before making any changes.

Author
The author

Aris Sentika

Aris is a Content Writer specializing in Linux and WordPress development. He has a passion for networking, front-end web development, and server administration. By combining his IT and writing experience, Aris creates content that helps people easily understand complex technical topics to start their online journey. Follow him on LinkedIn.