wordpress make new users not be able to see top bar

  1. Log in to your WordPress admin dashboard.

  2. Navigate to "Appearance" and select "Customize."

  3. In the Customizer, find and click on "Additional CSS."

  4. Add the following CSS code:

/ Hide WordPress admin bar for new users /
body.new-user.admin-bar .site {
    margin-top: 0;
}

body.new-user.admin-bar .navbar-fixed-top {
    display: none;
}
  1. Click "Publish" to save the changes.

  2. Install and activate the "Code Snippets" plugin if you haven't already.

  3. Go to "Snippets" in your WordPress dashboard.

  4. Click on "Add New."

  5. Title the snippet, paste the following PHP code, and set the snippet to run everywhere:

function hide_admin_bar_new_users() {
    if (current_user_can('administrator')) {
        return;
    }

    add_filter('show_admin_bar', '__return_false');
}

add_action('init', 'hide_admin_bar_new_users');
  1. Save and activate the snippet.

  2. Log out of WordPress and log in as a new user to test the changes.