Check if user has access to the group.
users_groupaccess( int $group_id ) : bool
$group_id (int) (Required) The ID of the group.
(bool) True if the user has access.
$id = 1;
if (users_groupaccess($id)) {
echo 'User has access to '.getgroupname($id);
}