Skip to content
ThemesIonic — home
WordPress Tutorials

How to Remove the WordPress Admin Bar

Hide the toolbar for yourself in one checkbox, for everyone below a certain role in three lines of code, and remove the space it reserves so the layout does not shift.

1 min read beginner

Quickest route: go to Users → Profile and untick Show Toolbar when viewing site. That is a per-user setting and affects nobody else — ideal when the toolbar just gets in your way while checking the front end.

For everyone, or for specific roles, use the code below.

Hide it for a single user

Users → Profile → Toolbar, untick, save. To do it for someone else, edit their profile under Users → All Users.

To set it for many users at once:

wp user meta update 5 show_admin_bar_front false

Hide it for everyone on the front end

Add this in a small custom plugin — not the theme, so it survives a theme change:

<?php
add_filter('show_admin_bar', '__return_false');

The dashboard is unaffected; only the front-end toolbar disappears.

Hide it for some roles

The common requirement on membership sites and stores: customers should not see the toolbar, staff should.

<?php
add_filter('show_admin_bar', function ($show) {
    // Anyone who can edit posts keeps the toolbar.
    return current_user_can('edit_posts') ? $show : false;
});

Test a capability rather than a role name, so custom roles behave predictably — the reasoning is in WordPress user roles explained.

To target one specific role:

<?php
add_filter('show_admin_bar', function ($show) {
    $user = wp_get_current_user();

    return in_array('customer', (array) $user->roles, true) ? false : $show;
});

Remove the space it reserves

WordPress adds a rule pushing the page down by the bar's height. Disable the toolbar with show_admin_bar and that rule goes with it. Hide it with CSS instead and the gap remains, because the margin is applied by a separate stylesheet.

If you inherited a site that hides it with CSS, clean it up:

/* Only needed when the bar is hidden rather than disabled. */
html.wp-toolbar {
    padding-top: 0 !important;
}
#wpadminbar {
    display: none;
}

The better fix is to remove that CSS and use the filter instead — see how to add custom CSS to WordPress for where such rules should live in the first place.

Also stop admin access, if that is the real goal

Hiding the toolbar does not stop a subscriber opening /wp-admin/. WordPress already blocks most screens by capability, but the profile page remains reachable. To redirect non-editors away:

<?php
add_action('admin_init', function () {
    if (! current_user_can('edit_posts') && ! wp_doing_ajax()) {
        wp_safe_redirect(home_url());
        exit;
    }
});

The wp_doing_ajax() check matters. Without it, front-end AJAX requests from plugins — carts, filters, forms — break, because they run through admin-ajax.php.

Notes

  • Removing the toolbar removes the quick "Edit page" link, which many editors rely on. Consider keeping it for anyone above contributor.
  • Some caching plugins vary output for logged-in users because of the toolbar. Disabling it can improve cache hit rates on membership sites — worth checking alongside how to clear the WordPress cache.
  • Plugins that add toolbar items are unaffected by the filter for the dashboard; they simply stop appearing on the front end.

Frequently asked

No. It only hides the front-end toolbar. You still reach the dashboard at /wp-admin/ exactly as before.
WordPress adds an html margin to make room for the bar. When the bar is hidden with CSS rather than disabled properly, the reserved space stays behind.
Yes. Test the user's capability — showing it only to users who can edit posts is the usual approach, which keeps it for authors and above.
Tagged CSS

Related guides