Index: units/helpers/user_helper.php =================================================================== --- units/helpers/user_helper.php (revision 13861) +++ units/helpers/user_helper.php (working copy) @@ -114,6 +114,7 @@ $this->Application->StoreVar('user_id', $user_id); $this->Application->SetVar('u.current_id', $user_id); $this->Application->Session->SetField('PortalUserId', $user_id); + $this->Application->Session->SetField('GroupId', reset($groups)); $this->Application->Session->SetField('GroupList', implode(',', $groups)); $this->Application->LoadPersistentVars(); Index: units/users/users_item.php =================================================================== --- units/users/users_item.php (revision 13861) +++ units/users/users_item.php (working copy) @@ -27,8 +27,12 @@ $user_groups = $this->Application->RecallVar('UserGroups'); if($user_groups === false || $force_reload) { - $sql = 'SELECT GroupId FROM %s WHERE (PortalUserId = %s) AND ( (MembershipExpires IS NULL) OR ( MembershipExpires >= UNIX_TIMESTAMP() ) )'; - $sql = sprintf($sql, TABLE_PREFIX.'UserGroup', $this->GetID() ); + // primary group goes first + $sql = 'SELECT GroupId + FROM ' . TABLE_PREFIX . 'UserGroup + WHERE (PortalUserId = ' . $this->GetID() . ') AND ( (MembershipExpires IS NULL) OR ( MembershipExpires >= UNIX_TIMESTAMP() ) ) + ORDER BY PrimaryGroup DESC'; + return $this->Conn->GetCol($sql); } else