Title: admin bar hidden for super admin
Last modified: April 29, 2026

---

# admin bar hidden for super admin

 *  Resolved [BrightLeaf Digital](https://wordpress.org/support/users/eitanatbrightleaf/)
 * (@eitanatbrightleaf)
 * [1 month, 2 weeks ago](https://wordpress.org/support/topic/admin-bar-hidden-for-super-admin/)
 * Hi, love your plugin. But it hides the admin bar for super admins even though
   it’s set to show for admins (and correctly does that).-
 * I asked Claude why (I didn’t have time to confirm or not if this is accurate)
   and this is what I got.
 * **File:** public/class-hide-admin-bar-based-on-user-roles-public.php:188-200
 * The `should_hide_for_user_capability()` method has a PHP gotcha with `explode()`:
 *     ```wp-block-code
       // When hab_capabilities is "" (empty — no caps entered in the Capabilities Blacklist)...
       $hab_capabilities = explode(",", "");
       // Returns: [""]  ← array with ONE empty-string element, NOT an empty array
       ```
   
 * PHP’s `explode(",", "")` always returns `[""]` rather than `[]`. The code then
   loops over that array and calls:
 *     ```wp-block-code
       current_user_can("")  // called with an empty string
       ```
   
 * For **super admins**, WordPress intercepts `user_has_cap` and grants **every**
   capability check — including an empty-string cap — returning `true`. For regular
   users, this call returns `false` because `""` isn’t in their `allcaps` array.
   That’s why only the super admin is affected.
 * In the meantime I didn’t touch the plugin code and fixed it with a snippet
 * <?php
   /**
    - Fix: “Hide Admin Bar Based On User Roles” incorrectly hides the bar
    - for super admins when the Capabilities Blacklist field is empty.
      *
    - Root cause: explode(“,”,””) returns [“”], and current_user_can(“”)
    - returns true for super admins due to WordPress’s super admin bypass.
      *
    - This filter runs after the plugin makes its show_admin_bar(false) call
    - and restores visibility for super admins.
      */add_filter( ‘show_admin_bar’, 
      function ( $show ) {if ( is_super_admin() ) {return true;}return $show;}, 
      20 );

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Ankit Panchal](https://wordpress.org/support/users/ankitmaru/)
 * (@ankitmaru)
 * [1 week, 4 days ago](https://wordpress.org/support/topic/admin-bar-hidden-for-super-admin/#post-18930223)
 * Hi, and thanks for the kind words, and for such a clear report! 🙏
 * You’re exactly right. When the Capabilities Blacklist is left empty, the plugin
   was making an empty capability check, which WordPress’s super-admin privileges
   treat as “allowed”, so the bar got hidden for super admins only.
 * I’ve fixed this at the source (empty entries are now ignored) and tested it across
   all configurations, existing setups are unaffected. It’ll go out in the next 
   update.
 * Your snippet is a fine temporary workaround until then; you can remove it once
   you’ve updated.
 * Thanks again for reporting it so thoroughly!
 * Best,
    Ankit
    -  This reply was modified 1 week, 4 days ago by [Ankit Panchal](https://wordpress.org/support/users/ankitmaru/).
    -  This reply was modified 1 week, 4 days ago by [Ankit Panchal](https://wordpress.org/support/users/ankitmaru/).
 *  Thread Starter [BrightLeaf Digital](https://wordpress.org/support/users/eitanatbrightleaf/)
 * (@eitanatbrightleaf)
 * [1 week, 3 days ago](https://wordpress.org/support/topic/admin-bar-hidden-for-super-admin/#post-18930944)
 * [@ankitmaru](https://wordpress.org/support/users/ankitmaru/) thanks so much! 
   looking forward to the patch!

Viewing 2 replies - 1 through 2 (of 2 total)

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fadmin-bar-hidden-for-super-admin%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](https://ps.w.org/hide-admin-bar-based-on-user-roles/assets/icon.svg?rev=3564176)
 * [Hide Admin Bar Based on User Roles](https://wordpress.org/plugins/hide-admin-bar-based-on-user-roles/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/hide-admin-bar-based-on-user-roles/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/hide-admin-bar-based-on-user-roles/)
 * [Active Topics](https://wordpress.org/support/plugin/hide-admin-bar-based-on-user-roles/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/hide-admin-bar-based-on-user-roles/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/hide-admin-bar-based-on-user-roles/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [BrightLeaf Digital](https://wordpress.org/support/users/eitanatbrightleaf/)
 * Last activity: [1 week, 3 days ago](https://wordpress.org/support/topic/admin-bar-hidden-for-super-admin/#post-18930944)
 * Status: resolved