Search code examples
modxmodx-revolution

How to get a list of all user groups in Modx Revolution


Trying to get a list of group names from modx revolution, digging through the API and docs, but not having much luck finding a function that does this.

How can I get a list of groups [names & ids] in a snippet from a modx revolution instance>?


Solution

  • <?php
    $where = array();
    $userGroups = $modx->getCollection('modUserGroup', $where);
    foreach ($userGroups as $userGroup) {
        print $userGroup->get('name');
    }