modUser.getUserGroups
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::getUserGroups¶
Returns the ids of the modUserGroup records joined through modUserGroupMembers for this User. Ids, not names: getUserGroupNames() returns the names for the same membership set.
Results are cached in the session under modx.user.{id}.userGroups and read only when this object is the currently logged in User. Any other User is queried from the database on every call, and the cache entry is rewritten with that result.
Syntax¶
array getUserGroups ()
Example¶
foreach ($user->getUserGroups() as $groupId) {
echo $groupId;
}
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










