When you log into your WordPress website, the WordPress admin toolbar will be displayed at the top of your site. This toolbar is used when accessing quick links to manage your site or when switching between the front-end and back-end of your website. Its not always needed though and if you have a website where people log in to view content on the front-end, you may want to disable showing the admin toolbar to these users.

In this guide we will be disabling the admin toolbar through settings and also site-wide using code.

The WordPress admin toolbar is displayed on the front-end and on the back-end of your site when you are logged in.

It is, however, not always wanted and can sometimes hinder the user experience. This is especially the case when you only want users to log into your site and view pages on the front-end. If the admin toolbar is present, it will display a link to view the back-end. That is why you can hide it to prevent the user from viewing the back-end of your site.

Often the toolbar can get in the way of some WordPress themes and other times you simply do not want it to be there.

Fortunately there is an easy fix!

The flexibility of disabling the admin toolbar is great. There are a number of options you can use to customize exactly how you want to hide the toolbar.

Disable the admin toolbar in profile settings

If you want to disable the admin toolbar when you are viewing your website for yourself then you can do so in your profile settings.

[highlight type=”note”]This method will turn off the admin toolbar only when you are logged in but it does not disable it for every other user. If your intention is to remove the toolbar for every user that logs in then you can do so with the next method.[/highlight]

Go to your profile settings by either hovering over your name in the top right hand side of the admin toolbar and selecting Edit My Profile.
Edit Profile User Admin Bar

Or access your profile settings by going to Users > Your Profile in the admin sidebar. Either way, it will take you to the same profile edit page.

User Profile Admin Sidebar

On this page, uncheck the Show Toolbar when viewing site checkbox and then click the Update profile button.

Disable Toolbar on WordPress front-end

Your admin toolbar will now be hidden when you are viewing the front-end of your website. That is all you need to do to disable the WordPress admin toolbar on the front-end. WordPress used to allow you to disable the toolbar in the back-end of your website but have since disabled that function.

If you would prefer to disable the admin toolbar by using code, in the next step we will disable it for all users.

Disable the admin toolbar site-wide for all users using code

When you want to disable the admin bar for all users, you need to overwrite the settings by using code.

The following code gets put into your child themes functions.php file.

[code type=”php”]// Disable WordPress admin toolbar for all users on the front-end
add_filter( ‘show_admin_bar’, ‘__return_false’ );[/code]

The above code adds a filter to tell WordPress to disable the admin bar for all users when they are logged in and viewing the front-end of your website.

This function can be modified to show the admin toolbar for certain user levels and hide it for other user levels. For example if you are the website administrator then you may want to keep the toolbar but for your subscribers, you want to hide the WordPress admin toolbar.

You can do this by putting the following code into your child themes functions.php file.
[code type=”php”]// Disable admin toolbar for all users except administrators on the front-end
function wpabsolute_hide_admin_bar($content) {
// Returns true if user is administrator, otherwise false.
return ( current_user_can( ‘administrator’ ) ) ? $content : false;
}
add_filter( ‘show_admin_bar’ , ‘wpabsolute_hide_admin_bar’);[/code]

The above code checks if you are an administrator and if you are, it will display the admin toolbar and if not it will hide it.

You can change the level of user access required to view the toolbar by changing the “administrator” value in the current_user_can function to something else. For example, if you want to show the toolbar to administrators and editor then you can use the capability of “edit_pages”. This will enable the toolbar for administrators and Editors but disable for all other users. The updated code would look like this:

[code type=”php”]// Disable admin toolbar for all users except administrators and editors on the frontend
function wpabsolute_hide_admin_bar($content) {
// Returns true if user is administrator or editor, otherwise false.
return ( current_user_can( ‘edit_pages’ ) ) ? $content : false;
}
add_filter( ‘show_admin_bar’ , ‘wpabsolute_hide_admin_bar’);[/code]

You can view a full list of available roles and capabilities on the WordPress Codex.

This tutorial gave you insight into how to disable the WordPress admin tool on the front-end of your website.

Even though you have disabled the admin bar, users that have logged in can still have access to view the dashboard or back-end of you website. Make sure you are disabling access to the admin dashboard too.

If you are building a membership style website then you can create your own custom login pages too.

Did this tutorial help you? Let us know in the comments below if there is anything more you would like to know on customizing your WordPress website.