modUser.getPrimaryGroup
Last updated not available | Page history | Improve this page | Report an issue
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$194 per month—let's make that $500!
Learn moremodUser::getPrimaryGroup¶
Returns null outright when the User is not authenticated in the current context, so the method is useless on a session-less object.
Otherwise it reads the PrimaryGroup aggregate behind the primary_group column. Without one it falls back to the membership row with the lowest rank, and stays null when the User is in no group at all. getDashboard() starts from this method.
Syntax¶
modUserGroup|null getPrimaryGroup ()
Example¶
$group = $user->getPrimaryGroup();
if ($group) {
echo $group->get('name');
}
See Also¶
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$194 per month—let's make that $500!
Learn more










