To get the groups array you can use this code:
$groupsb = (is_object($xoopsUser)) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
echo implode(' ',$groupsb);
Test case 1: my user admin with uid 1 is in the groups admins and registered users, so what do you expect to be printed?
Right! 1 2
Test case 2: my user admin with uid 1 is in the groups admins, so what do you expect to be printed?
WRONG! It prints 1 2
Why is this so? I can't find any solution for this "odd" behaviour. When this is expected behaviour, then this is bollocks. I made a fresh install of 2.4.4 to avoid any collisions and if I remember correctly in the 2.0 series it worked as I expected.