# Disabling the WordPress admin bar for all users using PHP

> Hide the WordPress admin bar on the front end for all logged-in users with a short PHP snippet.

Source: https://helpcenter.ruachost.com/wordpress/guides/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.

## Why Disable the Admin Bar?

- 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.

## Steps to Disable Admin Bar via PHP

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.

## Important Notes

- 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.
