Menu Visibility

I would like to show a certain product category in the menu only if the current user is in my ‘Premium’ group. I have been able to make dynamic menu items with simple conditionals such as is_user_logged_in() to only show a menu item if a user is logged in or in_array('administrator', $GLOBALS['current_user']->roles) to only show a menu item if a user is an administrator, etc. Is there a similar conditional I can use to test if the current user is in my ‘Premium’ group?


Comments

2 responses to “Menu Visibility”

  1. Travis Avatar

    Thank you! This worked perfectly!

  2. antonio Avatar
    antonio

    Hi,
    this can help you:
    $result = false;
    require_once(ABSPATH . "wp-includes/pluggable.php");
    if ( $group = Groups_Group::read_by_name( 'Registered' ) ) {
    $result = Groups_User_Group::read( get_current_user_id() , $group->group_id );
    }
    return $result;

    That would show the widget to users in the Registered group only.
    cheers

Share