Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

To hide the WordPress front-end Toolbar from users who do not have a chosen capability, add a show_admin_bar filter in your theme’s functions.php or, preferably, a site-specific plugin:

add_filter( 'show_admin_bar', function ( $show ) {
    if ( ! current_user_can( 'manage_options' ) ) {
        return false;
    }

    return $show;
} );

This keeps the Toolbar for users with manage_options and hides it for everyone else. The rule applies to the public-facing site, not the WordPress dashboard.

Use a capability, not an administrator role name

manage_options is a common choice for retaining the Toolbar for administrators on a standard single-site installation. It is a capability check, not a universal definition of “administrator.” Custom roles and multisite configurations can assign capabilities differently, so replace it with the capability that matches your policy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For example, if a custom role should keep the Toolbar because it has a specific editorial capability, test that capability instead:

if ( ! current_user_can( 'edit_others_posts' ) ) {
    return false;
}

Do not use is_admin() for this decision. That function identifies whether the current request is for the administrative interface; it does not identify the current user as an administrator.

Where to put the code

Site-specific plugin

A small site-specific plugin is the most durable location because the rule remains active when you change themes. Add the snippet to a PHP file in the site-specific plugin, then activate it from Plugins in WordPress.

Theme functions file

You can also add it to the active theme’s functions.php. A child theme is safer than editing a parent theme, because parent-theme updates can overwrite changes. Keep the PHP opening tag supplied by the file and paste the snippet outside any other function.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What the filter does

show_admin_bar is WordPress’s documented filter for controlling the front-end Toolbar (the newer name for the Admin Bar). Returning false prevents the Toolbar from being displayed on public-facing pages. Returning the incoming $show value preserves WordPress’s existing decision for users who pass your capability check.

The filter is conditional: it can enforce a capability-based site policy while still allowing WordPress’s normal per-user setting to apply to permitted users.

Admin Bar versus dashboard

This filter controls the Toolbar on the front end of the site. It does not turn off the Toolbar in wp-admin under current WordPress behavior. A user who is allowed to access the dashboard can therefore still see the dashboard Toolbar even when the front-end bar is hidden.

Rank #4
A Complete Guide to the Soul
  • New
  • Mint Condition
  • Dispatch same day for order received before 12 noon
  • Guaranteed packaging
  • No quibbles returns

That scope matters when diagnosing results: test on a public page while logged in as a user who lacks the selected capability, rather than only checking a dashboard screen.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Hide the Toolbar for everyone

If your policy is unconditional, use WordPress’s supported show_admin_bar() function instead of a capability test:

show_admin_bar( false );

WordPress documents this function for immediate use when a plugin loads or for placement in a theme’s functions.php. It sets the Toolbar status for the applicable request. For a rule that differs by user, the filter remains the clearer option.

Approach Best for Decision Scope Per-user preference
show_admin_bar filter Non-administrator or capability-based policies Conditional; commonly uses current_user_can() Front end Can be overridden for users who pass the condition
show_admin_bar( false ) Hiding the Toolbar for everyone in the applicable context Unconditional Applicable request context; the filter’s dashboard limitation still applies to the main front-end solution Site code sets the status
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How WordPress’s personal setting interacts with the rule

Each user has a front-end display preference stored as show_admin_bar_front. When that preference is unset, WordPress normally shows the Toolbar. A user can also disable it in their profile. Your filter adds a site-level rule: users who lack the tested capability are forced to false, regardless of their personal preference; users who pass the test retain WordPress’s existing result.

Do not unhook WordPress’s private initializer

Avoid removing the private _wp_admin_bar_init() function with remove_action(). WordPress explicitly warns that unhooking it does not properly remove the Admin Bar and directs developers to show_admin_bar( false ) or the show_admin_bar filter instead. The documented APIs are safer for themes and reusable plugins.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Common mistakes and fixes

  • Testing is_admin(): this checks request location, not user permissions. Use current_user_can( 'manage_options' ) or your policy’s capability.
  • Expecting the dashboard bar to disappear: the filter is for the front end. Verify the result on a public URL.
  • Assuming every administrator has the same capability: inspect the capabilities assigned to custom roles and multisite users, then choose the one your rule actually requires.
  • Editing a parent theme: place the code in a child theme or site-specific plugin so updates do not remove it.
  • Using a private core hook: use the documented function or filter rather than unhooking _wp_admin_bar_init().

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.