Your third one looks like it should work, though it’s a bit hard to read. I’d recommend something like this:
add_filter( 'show_admin_bar', 'wpse424492_admin_bar', 10000 );
function wpse424492_admin_bar( $show ) {
if ( current_user_can( 'manage_options' ) ) {
// Show the admin bar for Admins.
return true;
}
// Hide the admin bar for anyone else.
return false;
}
I’ve added a high priority (10000) to try and have it override any other functions hooked to the filter.
Related Posts:
- Changing Admin Menu Labels
- Is there ANY way to remove comments function and section totally?
- Unit testing in the WordPress backend (is_admin() is true)
- How to display a static HTML page while setting up a WordPress site?
- How can I uninstall a language?
- Best way to present options for home page in admin?
- How do I change the login logo URL and hover title?
- js error on post editing page
- How to add a custom metabox to the Menu Management admin screen?
- How to change the wording in wp-admin back-end?
- How to make ajax call in wordpress in right way?
- Delete Post From front Page ( With Wp-admin restriction )
- Custom user role that can only edit specific (non-custom-type) page and all child pages [duplicate]
- Bulk Delete Users Error uri too large
- Add button in TinyMCE editor to insert text
- Can you change the main heading of a page in the WordPress admin (without output buffering or JavaScript)?
- Add column to pages table
- How to get the password and username of the add new user form (admin back end) in wordpress
- Change the Return URL from the Customizer
- Where can I edit Admin Panel Page file
- WordPress Error establishing a database connection For Admin login only
- Image editing: “Edit Original” and “Replace” buttons missing on old posts
- Replace wordpress login logo with custom text
- Failed to load resource admin-ajax.php
- Additionally added URL params leading to “Invalid post type.” in the Admin Panel
- Custom WordPress Dashboard for Specific user role
- After login get “403 Forbidden”
- Why are my frontend theme styles bleeding into the backend?
- Show Welcome Panel on Dashboard for every user
- 404 of wp-admin pages [closed]
- Execute script only on certain admin pages
- Uncheck the box “Send User Notification” by default on new-user.php
- Detecting all admins that are logged in
- WordPress Options Page not working
- Admin account locked out/redirect loop. Other accounts work?
- Sortable columns and admin like interface for tables/report in custom plugin?
- Remove favorites action menu and screen options panel
- No access local wordpress website after PC formating
- How to prevent the editor from redirecting to website within iframe?
- is_admin() not working when updating a post in the admin panel
- Why is server preventing admin styles? (Was: Where are WordPress sessions saved?)
- White screen of death in Dashboard after clean installation
- WordPress (admin) posts search GET request filter
- How can I replace dashboard.css and dashboard.min.css (not add new css)
- wp-admin throwing 500 errors after update to 4.2.1
- ‘wp’ hook supposed to trigger when editing a post?
- How to remove dashboard access (wp-admin) for author but not disable the capabilities?
- always by default show welcome panel in the dashboard
- Migrated wordpress site give “Undefined variable: php” warnings
- Add and Remove Row Actions in an Existing WP_List_Table
- I am unable to login into my wp-admin
- Is it possible to take over a WordPress site if the old administrator is MIA?
- Dashboard Widget CSS
- How can I prevent a function from loading in the admin screens?
- Move WooCommerce menu entries to top of dashboard
- WP Core hard coded to use http://www.w3.org/1999/xhtml not HTTPS
- Hide user group filtering links
- 404 Admin Error
- Fix Admin Dashboard Posts tab
- auto generated robots.txt problem
- Change maxlength of link_description in dashbord link section?
- Add a custom field when adding / editing a page / post in admin panel
- View all comments on post one click
- I can’t access my wp admin dashboard
- Should I move wp-admin to a separated server? How to do it?
- WP-Admin throws 404 after changing wp-config Salts
- How to create a new section on the wordpress admin dashboard?
- What event I can tap into that fires before loading wp-admin page?
- Weird white space in admin area
- How to logout the current user without notices and warnings?
- Updated to wordpress 5.5.1 doesn’t work
- How can I change block editors suggested links to display another url (i.e. from api.mysite to www.mysite)
- How to fix the view of admin all posts
- mixed contents admin panel is Unsecured
- Link with password is not sent to the new user
- Can I rename the wp-admin folder?
- How do I list subpages in post editor view?
- Remove View details option from plugin listing
- WordPress wp-admin login problem
- WordPress Admin Page Redirecting to Subdomain
- Remove Theme menu link from Admin Panel
- Why does my edit screen suddenly have such a buggy interface?
- Disabling WP-Admin Caching in htaccess
- Unable to log in as admin
- Add files to wordpress admin panel footer
- WordPress Child problem in admin
- SSL doesn’t deliver parts of WordPress Administration Module
- WordPress admin option, I can’t use jquery ajax to access my content from another file
- How to display product category’s individual product list in shop page?
- WordPress br in content problem
- How to troubleshoot 404s in WordPress admin
- Launch wordpress site to local computer from live website backed-up
- How do I unset all of the select boxes for pages
- wp-admin won’t “remember me” in Chrome & Firefox
- Move Custom Taxonomy Menu to Top Level Admin Menu
- Extend user search in the users.php page to allow for searching by role and excluding specified email domains from the “users search” input box
- get_current_screen() does not return parent_file
- Valid WordPress html elements
- Unable to access WordPress admin panel
- Is it possible to hide or encrypt the display name after login into the WordPress admin panel?