Skip to content

Using PHP to Disable WordPress Admin Bar for All Users

By default, WordPress displays the admin bar at the top of the site for all logged‑in users. While useful for administrators, it may clutter the interface for other users. On ruachost.com, you can disable the admin bar globally with a simple PHP snippet.

  • Provides a cleaner front‑end experience for logged‑in users.
  • Prevents non‑admin users from accessing admin shortcuts.
  • Useful for membership sites or blogs where the admin bar is unnecessary.
  1. Log in to WordPress with an administrator account.

  2. In the dashboard, go to Appearance → Theme Editor.

  3. Select your active theme and open the functions.php file.

  4. Add the following code snippet at the end of the file:

    // Disable WordPress admin bar for all users
    add_filter('show_admin_bar', '__return_false');
  5. Click Update File to save changes.

  6. Refresh your site → The admin bar will no longer appear for any user.

  • Always back up your theme files before editing.
  • Use a child theme to preserve changes during theme updates.
  • This disables the admin bar for all users, including administrators.
  • If you want to disable it only for specific roles (e.g., subscribers), you’ll need a conditional PHP check.