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 */

show_admin_bar(false);

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 ) ) {
            show_admin_bar(false);
        }
    }
}

 

I hope this post will help you. Thanks.

20 thoughts on “Remove the WordPress admin toolbar from site

  1. We selling Gmail Fresh – facebook – Instagram accounts.
    This type of account is created freshly of the same year. We can provide you as much you need. All accounts will be phone verified, after purchasing you can change the password and recovery details.

    if you have any question​,Messenger me Contact :​

    Telegram & Skype : congmmo
    Email : ​congmmo @gmail.com​

    Order Here
    https://sellaccs.net

    Tags:
    buyaccs, bulk gmail accounts, buy bulk gmail accounts, gmail accounts bulk, buy bulk yahoo account, buy verified youtube accounts, cheap twitter accounts, buy livejournal accounts,
    bulk accounts 1k yahoo, yahoo hotmail bulk gmail pva, buy gmail email bulk, buy facebook accounts pva, facebook pva for sale, buy facebook pva accounts, cheapest facebook accounts buy,
    buy pva accounts facebook, buy gmail pva accounts, buy facebook accounts, buy pva facebook accounts, bulk hotmail, buy bulk twitter accounts, cheap pva gmail account,
    buy facebook pva account, pva facebook accounts free, how to create bulk account in facebook, buy gmail accounts in bulk, order mass facebook and twitter accounts

  2. [url=https://black-tip.top/forums/obuchenie.86/]белая схема[/url] – дроп сервис USA, куплю аккаунты социальных

  3. Hello, you used to write fantastic, but the last several posts have been kinda boring… I miss your tremendous writings. Past few posts are just a little bit out of track! come on!

  4. You can certainly see your expertise within the paintings you write. The arena hopes for more passionate writers such as you who are not afraid to say how they believe. Always follow your heart.

  5. Hi there. I found your web site by the use of Google at the same time as looking for a related topic, your website got here up. It seems good. I have bookmarked it in my google bookmarks to visit then.

Leave a Reply

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