Your cart is currently empty!
Menu Visibility
—
by
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?
Posted in Groups Restrict Categories
Comments
2 responses to “Menu Visibility”
Thank you! This worked perfectly!
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