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: {% ???? %}
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 #
{{ group.name }}
{% 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 #
{{ group.name }}