Support » Plugin: Menu Item Visibility Control » hiding menu to specific membership

  • What’s the code for hiding the menu to specific member role only when members logged in?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author shazdeh


    You can use:

    is_user_logged_in() && in_array( 'administrator', $GLOBALS['current_user']->roles )

    Is this for hiding or showing?

    I need hiding to specific role.

    Plugin Author shazdeh


    The above snippet makes the menu show only when the user is an “administrator” (when the condition returns true, the menu item shows). To flip the logic, you can simply use the ! (NOT) operator:

    ! in_array( 'administrator', $GLOBALS['current_user']->roles )
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘hiding menu to specific membership’ is closed to new replies.