Skip to content

Instantly share code, notes, and snippets.

@Rachind
Forked from pepebe/gist:2483894
Created October 29, 2021 07:54
Show Gist options
  • Save Rachind/bb1bcc20beb11fc0caf55ec298195678 to your computer and use it in GitHub Desktop.
Save Rachind/bb1bcc20beb11fc0caf55ec298195678 to your computer and use it in GitHub Desktop.
MODx: Get all members of a user group in MODx Revolution.
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');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment