Remove the WordPress admin toolbar from site

Sometime client having requirement to disable admin toolbar because its disturbing site layout or maybe we want to remove this toolbar for specific custom wp roles as per client said. So there is 2 ways to achieve this task. First one we can manage it from wordpress backend settings and second one we can hide it programmatically.

1. Disable admin toolbar from profile settings permanently.

To remove the toolbar parmanently from your website, follow below steps :
1. Go to “Users” menu
2. Your Profile
3. Scroll down to Toolbar option
4. Check this option “Show Toolbar when viewing site”.

Check Admin toolbar settings :

2. Disable admin toolbar programmatically.

If you want to Disable admin toolbar programmatically then you just simple have to use below line :

/* Disable admin toolbar for all users */

We can also disable toolbar for specific user roles. For example I have created two roles “organiser” and “assistant_organiser”.  And below code is to hide admin toolbar for these two roles users.

Just go to your theme and look for functions.php and add below scripts in end of the file and save it.

add_action('init', 'hide_admin_bar_for_specific_roles');

function hide_admin_bar_for_specific_roles(){
    if ( is_user_logged_in() ) {
        $user = wp_get_current_user();
        if ( in_array( 'organiser', (array) $user->roles ) || in_array( 'assistant_organiser', (array) $user->roles ) ) {

I hope this post will help you. Thanks.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.