Created
April 24, 2012 21:17
-
-
Save pepebe/2483894 to your computer and use it in GitHub Desktop.
MODx: Get all members of a user group in MODx Revolution.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
by kairon - http://www.unchi.co.uk/author/admin/ | |
Get all members of a user group in MODx Revolution. This can been done by accessing the database in the following way. | |
<?php | |
$usergroup = 4; | |
$c = $modx->newQuery('modUser'); | |
$c->innerJoin ('modUserProfile','Profile'); | |
$c->innerJoin ('modUserGroupMember','UserGroupMembers'); | |
$c->innerJoin ('modUserGroup','UserGroup','`UserGroupMembers`.`user_group` = `UserGroup`.`id`'); | |
$c->leftJoin ('modUserGroupRole','UserGroupRole','`UserGroupMembers`.`role` = `UserGroupRole`.`id`'); | |
$c->where(array( | |
'active' => true, | |
'UserGroupMembers.user_group' => $usergroup, | |
'UserGroupMembers.role' => '5', | |
)); | |
$users = $modx->getCollection('modUser',$c); | |
foreach($users as $var => $value) | |
{ | |
// Here you can get profile information e.g. $profile = $user->getOne('Profile'); | |
} |
it can be as is then $profile = $value->getOne('Profile');
or in order to be it more consistent the foreach should iterate as you suggest.
just tested and confirmed.
Hope it helps
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
shouldn't it be this?
foreach ($users as $user)