• Resolved ehmarketing

    (@ehmarketing)


    Hello there,

    I am creating a ‘Wholesale’ page and I want to hide other ‘general customer’ products from people signed in as Wholesale user role.

    I was looking to just hide the shop menu on the ‘Wholesale page’ but I realised that the menu will reappear on Checkout. Is there a way to hide the shop menu on all pages to certain User types (in this case Wholesale user roles).

    Thanks!

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

    (@cedcommerce)

    Hello,

    You can do this by following this approach.

    Get the current user logged in ID using, and then find the user role from user id, then you can remove the menu (i.e on conditional basis),

    $user_id = get_current_user_id();
    
    $user_meta=get_userdata($user_id);
    
    $user_roles=$user_meta->roles;
     
    $menu_slug = 'menu_slug_you_want_remove';
    
    if($user_roles == 'Wholesale user'){
       remove_menu_page( $menu_slug );
    }

    Thanks,

    Plugin Support Yuki K a11n.

    (@yukikatayama)

    Automattic Happiness Engineer

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide shop menu based on User role’ is closed to new replies.