Answers.Body: <p>If you know the user will only belong to one group, something like this should do it.</p>
  
  <pre><code>{% set user = craft.users.username(craft.request.getSegment(2)).first() %}
  
  {# make sure we found a user %}
  {% if user|length %}
      {% set groups = user.getGroups() %}
  
      {# make sure they belong to at least one group #}
      {% if groups|length %}
          {# display the name of the first group #}
          {{ groups[0].name }}
      {% endif %}
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-09T18:24:15.720Z
Answers.Text: Thanks Brad! That worked. So, is there any clarification you can give as to why the previous example in the other thread didn't work for my case?
Answers.UserDisplayName: Chase Giunta
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-10T18:58:23.377Z
Answers.Text: Btw, something like this (checking for user group based on URL) seems like it should be a simple task (obviously it's not) & useful example to have in the docs. Along with a ton of others!
Answers.UserDisplayName: Chase Giunta
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-09T18:20:01.397Z
Answers.LastActivityDate: 2015-03-09T18:20:01.397Z
Answers.UserDisplayName: Brad Bell
Answers.Body: <p>If you only want to get the user if they are A) in the group identified in the 1st segment, and B) have the username in the 2nd segment, you can do this:</p>
  
  <pre><code>{% set user = craft.users({
      group:    craft.request.getSegment(1),
      username: craft.request.getSegment(2)
  }).first() %}
  
  {# Make sure we found someone #}
  {% if not user %}
      {% exit 404 %}
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-13T20:48:27.120Z
Answers.LastActivityDate: 2015-03-13T20:48:27.120Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>This two-part question is half an exact duplicate of <a href="https://craftcms.stackexchange.com/questions/1578/how-do-you-display-a-users-user-group">How do you display a user&#39;s User Group?</a> but I'm unable to leave a comment :(</p>
  
  <p>I'm trying to display &amp; check-for the user group a user belongs to on a public profile page. There are coaches and players.</p>
  
  <p>The URL structure is <code>domain.com/coaches/johnnyappleseed</code></p>
  
  <p>Copying the exact example code given in the original question (link above) seems to just return the User's full name, not the group the user belongs to. What could I be missing?</p>
  
  <p>Also, if johnnyapplseed is a coach, I can still access his profile page by going to <code>domain.com/players/johnnyappleseed</code> which is why I'm trying to check for the usergroup to begin with. Is checking for the usergroup in each player &amp; coach profile template the correct way to do this?</p>
  
  <p>UPDATE: I've attached a screenshot of all the information I think could possibly be relevant. This has to be something simple I'm overlooking!</p>
  
  <p><img src="https://i.sstatic.net/3CtYV.jpg" alt="enter image description here"></p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-09T15:36:43.800Z
Comments.Text: Can you edit your question and share the template code you're using?  The first example in the link you shared should definitely display the user groups a user belongs to.
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-09T17:14:06.877Z
Comments.Text: @BradBell I've attached a screenshot, hopefully I grabbed all relevant information. (copy img URL to view full-size)
Comments.UserDisplayName: Chase Giunta
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-09T17:25:18.230Z
Comments.Text: If you `{{ thePartner }}` and `{{ group }}` what does it output in the browser?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-09T17:28:25.523Z
Comments.Text: @BradBell `{{ group }}` returns the username "johnnyappleseed" . `{{ thePartner }}` gives me an
  `Object of class Craft\ElementCriteriaModel could not be converted to string` error
Comments.UserDisplayName: Chase Giunta
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-09T17:30:00.143Z
Comments.Text: Ahh... add a `.first()` to the end of the `craft.users.username` line and see if that helps.
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-09T17:36:20.190Z
Comments.Text: @BradBell http://cl.ly/image/2C1u1x1w2n0t ? Did I add that in the correct place?
Comments.UserDisplayName: Chase Giunta
Tags: <user-groups>
Title: Display & check-for User Group on public profile
ThreadText: # Display & check-for User Group on public profile
  
  (Asked by: username_0 on 2015-03-09)
  
  This two-part question is half an exact duplicate of [How do you display a user's User Group?](https://craftcms.stackexchange.com/questions/1578/how-do-you-display-a-users-user-group) but I'm unable to leave a comment :(
  
  I'm trying to display & check-for the user group a user belongs to on a public profile page. There are coaches and players.
  
  The URL structure is `domain.com/coaches/johnnyappleseed`
  
  Copying the exact example code given in the original question (link above) seems to just return the User's full name, not the group the user belongs to. What could I be missing?
  
  Also, if johnnyapplseed is a coach, I can still access his profile page by going to `domain.com/players/johnnyappleseed` which is why I'm trying to check for the usergroup to begin with. Is checking for the usergroup in each player & coach profile template the correct way to do this?
  
  UPDATE: I've attached a screenshot of all the information I think could possibly be relevant. This has to be something simple I'm overlooking!
  
  ![enter image description here](https://i.sstatic.net/3CtYV.jpg)
  
  **Tags:** user-groups
  
  > **Comments:**
  > **username_1**: Can you edit your question and share the template code you're using?  The first example in the link you shared should definitely display the user groups a user belongs to.  
  > **username_0**: @username_1 I've attached a screenshot, hopefully I grabbed all relevant information. (copy img URL to view full-size)  
  > **username_1**: If you `{{ thePartner }}` and `{{ group }}` what does it output in the browser?  
  > **username_0**: @username_1 `{{ group }}` returns the username "johnnyappleseed" . `{{ thePartner }}` gives me an `Object of class Craft\ElementCriteriaModel could not be converted to string` error  
  > **username_1**: Ahh... add a `.first()` to the end of the `craft.users.username` line and see if that helps.  
  > **username_0**: @username_1 http://cl.ly/image/2C1u1x1w2n0t ? Did I add that in the correct place?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-03-09. Score: 2 | Accepted answer
  
  If you know the user will only belong to one group, something like this should do it.
  
  ```
  {% set user = craft.users.username(craft.request.getSegment(2)).first() %}
  
  {# make sure we found a user %}
  {% if user|length %}
      {% set groups = user.getGroups() %}
  
      {# make sure they belong to at least one group #}
      {% if groups|length %}
          {# display the name of the first group #}
          {{ groups[0].name }}
      {% endif %}
  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks username_1! That worked. So, is there any clarification you can give as to why the previous example in the other thread didn't work for my case?  
  > **username_0**: Btw, something like this (checking for user group based on URL) seems like it should be a simple task (obviously it's not) & useful example to have in the docs. Along with a ton of others!  
  
  ---
  
  ### Answer by username_2 on 2015-03-13. Score: 1
  
  If you only want to get the user if they are A) in the group identified in the 1st segment, and B) have the username in the 2nd segment, you can do this:
  
  ```
  {% set user = craft.users({
      group:    craft.request.getSegment(1),
      username: craft.request.getSegment(2)
  }).first() %}
  
  {# Make sure we found someone #}
  {% if not user %}
      {% exit 404 %}
  {% endif %}
  
  ```
  
  
  ---
  
  