modUser.isMember
Last updated Nov 27th, 2019 | 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::isMember¶
Checks whether a User belongs to one or more User Groups.
Syntax¶
boolean isMember (string|array $groups [, boolean $matchAll = false])
| Parameter | Description |
|---|---|
$groups |
User Group name or an array of User Group names |
$matchAll |
true — require membership in every group of the array; false (default) — membership in any one group is enough. No effect when $groups is a single string. |
Example¶
Get a User object:
$user = $modx->getObject('modUser', array('username' => 'boss'));
Check membership in the 'Staff' User Group:
$user->isMember('Staff');
Check membership in either the 'Staff' or the 'Investors' User Group:
$user->isMember(array('Staff','Investors'));
Check membership in both User Groups at once:
$user->isMember(array('Staff','Investors'), true);
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










