Search code examples
razorumbraco

How do I list all member groups in Umbraco?


I am currently trying to create a page where I have a list of all the groups in the the Umbraco member area.

Most of what is returned when I google for an answer is how to get all the groups for a specific user, however this is not what I want, I would like all the groups listed that are available for all members.

I guess the alternative is to create a user that has permission for all the groups and then loop through that member's groups, but this would require me to ensure that this member is added to every new group I create.


Solution

  • I have found the answer for anyone looking (Thank-you Stack Overflow for your rubber duck effect!)

    @{
      string[] Roles = System.Web.Security.Roles.GetAllRoles();
    }
    <ul>
      @foreach (string role in Roles) {
        <li>@role</li>
      }
    </ul>