We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19726
    • 239 Posts
    I am trying to make a snippet that displays the fullname of all webusers in a specific group. I could not find an API call for this, so I tried querying the database directly instead, but I just can’t figure out the correct SQL to use. I can get the correct groupid from a given groupname. The problem is to get the list of fullnames of the users that are in that group. Would any of the SQL guru’s out there be so kind to help me out with this query?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      I will be doing that in the morning; I’ll post the query when I get it working.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 22303 MODX Staff
        • 10,725 Posts
        Quote from: Mitch at Aug 27, 2006, 12:38 PM

        I am trying to make a snippet that displays the fullname of all webusers in a specific group. I could not find an API call for this, so I tried querying the database directly instead, but I just can’t figure out the correct SQL to use. I can get the correct groupid from a given groupname. The problem is to get the list of fullnames of the users that are in that group. Would any of the SQL guru’s out there be so kind to help me out with this query?


        This should do it (PHP tags for code highlighting only):
        <?php
        $wua= $modx->getFullTableName('web_user_attributes');
        $wgn= $modx->getFullTableName('webgroup_names');
        $wg= $modx->getFullTableName('web_groups');
        $sql= "SELECT wua.fullname FROM {$wua} wua JOIN {$wg} wg ON wg.webuser = wua.internalKey JOIN {$wgn} wgn ON wgn.name = '{$webGroupName}' AND wgn.id = wg.webgroup";
        ?>
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Oooh, thank you! I needed to do that for a project I’m working on, and now I don’t have to work it out! (except I want the email too, but that’s no big deal).
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 19726
            • 239 Posts
            Thanks a lot for the help. Expect a new snippet in the repository later this week smiley
              • 19726
              • 239 Posts
              I had less time than expected, but here it is: http://modxcms.com/ShowMembers-957.html