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?

2 Responses to Menu Visibility

  1. Travis May 15, 2014 at 4:12 pm #

    Thank you! This worked perfectly!

  2. antonio May 15, 2014 at 6:22 am #

    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

We use cookies to optimize your experience on our site and assume you're OK with that if you stay.
OK, hide this message.

Affiliates · Contact · Jobs · Terms & Conditions · Privacy Policy · Documentation · Downloads · Useful Plugins · My Account

Share