Index: branches/5.2.x/core/units/helpers/user_helper.php =================================================================== diff -u -N -r14244 -r14432 --- branches/5.2.x/core/units/helpers/user_helper.php (.../user_helper.php) (revision 14244) +++ branches/5.2.x/core/units/helpers/user_helper.php (.../user_helper.php) (revision 14432) @@ -1,6 +1,6 @@ Application->Session->SetField('PortalUserId', $user_id); if ($user_id != USER_ROOT) { - $this->Application->Session->SetField('GroupList', $this->Application->RecallVar('UserGroups')); + $groups = $this->Application->RecallVar('UserGroups'); + $this->Application->Session->SetField('GroupId', reset( explode(',', $groups) )); + $this->Application->Session->SetField('GroupList', $groups); } $this->Application->LoadPersistentVars(); Index: branches/5.2.x/core/units/users/users_item.php =================================================================== diff -u -N -r14244 -r14432 --- branches/5.2.x/core/units/users/users_item.php (.../users_item.php) (revision 14244) +++ branches/5.2.x/core/units/users/users_item.php (.../users_item.php) (revision 14432) @@ -1,6 +1,6 @@ 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