Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This seems simple, but I cannot get it to render -- how do display a user's User Group? Assuming I set the user in segment 2:

{% set thePartner = craft.users.username( craft.request.getSegment(2) ) %}
This Is My User Group: {% ???? %}
share|improve this question
up vote 3 down vote accepted

The UserModel has a getGroups() function which:

Returns an array of UserGroupModel objects that the user belongs to.

Since a user can belong to multiple usergroups, you have to loop through the array containing them:

{% set thePartner = craft.users.username( craft.request.getSegment(2) ) %}

# Loop through array of UserGroupModels #
{% for group in thePartner.getGroups() %}
    # Print name of current UserGroupModel #
    {{ }}
{% endfor %}

If you are sure the user only belongs to one group, you can fetch the first UserGroupModel from like this:

{% set thePartner = craft.users.username( craft.request.getSegment(2) ) %}

# Get first UserGroupModel #
{% set group = thePartner.getGroups().first %}

# Print name #
{{ }}
share|improve this answer
Perfect, thank you -- that did the trick nicely. – Shanan Galligan Aug 2 '14 at 18:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.