We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8813
    • 18 Posts
    Hello

    I need to retrieve all the users from the system and display their roles and groups in a table
    <table>
    
    <tr>
    <td>id</td>
    <td>name</td>
    <td>group1</td>
    <td>group3</td>
    <td>group3</td>
    </tr>
    
    <tr>
    <td>1</td>
    <td>Mister A</td>
    <td>Group1 : Member</td>
    <td>Group2 : Admin</td>
    <td>Group : Member</td>
    </tr>
    
    </table>


    Is there a way to do this with the api?

    Regards
      • 3749
      • 24,544 Posts
      Yes, but it's a bit tricky because the information you want is in four different database tables. Also, I don't think your table structure will work very well unless all users are in exactly the same number of groups or there are a small number of groups and you don't mind having blank cells. Just doing it with li or span tags might be a better option -- it would make for simpler code.


      Do you need the user's full name (if so, it's 5 tables) or would the username do? Using the username would make it faster and easier, but you might not want to expose the username to the public for security reasons. Giving hackers a complete list of all usernames on your site creates a great option for a brute-force attack on the site.

        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting