how to hide sidebar admin menu?


I would like to know how I could hide the sidebar menu in the wordpress dashboard, but just for subscriber+admin+editor role and keep for superadmin role. I have difficulty to hide but keep for superadmin

In fact, I just want people to see the toolbar but not the menu on the left.

Thank you


  • Michael Bissett
    • Recruit

    Hey @Ludovic, hope you're doing well today! :slight_smile:

    You can do this by using our Ultimate Branding plugin, along with some custom CSS & PHP code.

    After installing Ultimate Branding, you'll want to insert the following code into your site as a mu-plugin:

    function role_admin_body_class( $classes ) {
        global $wpdb, $current_user;
        if (is_super_admin()) {
              $classes .= 'superadmin';
        } else {
              foreach( $current_user->roles as $role ) {
                    $classes .= ' role-' . $role;
        return trim( $classes );
    add_filter( 'admin_body_class', 'role_admin_body_class', 50 );

    Then, after enabling the Custom Admin CSS module inside of Ultimate Branding, you can insert this CSS code in there to hide that menu for the roles you mentioned:

    .role-administrator #adminmenuwrap, .role-editor #adminmenuwrap, .role-subscriber #adminmenuwrap {
        display: none;
    .role-administrator #adminmenuback, .role-editor #adminmenuback, .role-subscriber #adminmenuback {
        display: none;
    .role-administrator #wpcontent, .role-editor #wpcontent, .role-subscriber #wpcontent {
        margin-left: 0;

    Hope this helps! :slight_smile:

    Kind Regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.