The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →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.
For example, if a custom role should keep the Toolbar because it has a specific editorial capability, test that capability instead:
#1 Best Overall
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.
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
- 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.
Hide the Toolbar for everyone
If your policy is unconditional, use WordPress’s supported show_admin_bar() function instead of a capability test:
Best Value
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 |
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.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallQuick Recap
Common mistakes and fixes
- Testing
is_admin(): this checks request location, not user permissions. Usecurrent_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.

