Answers.Body: <p>I believe your problem lies in the parameter for user group. In Twig, you don't need the brackets if you're already in brackets. You just reference the variable and fields directly. So instead of:</p>
  
  <pre><code>{% set group = craft.users.group('{{ category.slug }}') %}
  </code></pre>
  
  <p>Try this:</p>
  
  <pre><code>{% set group = craft.users.group(category.slug) %}
  </code></pre>
  
  <p>You see, the ElementCriteriaModel that's parsing the parameter for group doesn't run all its function arguments through Twig. So you're confusing it by throwing braces in there. Just give it the variable and field without quotes or braces and it should work smashingly, provided that <code>category.slug</code> is the same as a group <code>slug</code>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-04T13:22:17.900Z
Answers.LastActivityDate: 2016-01-04T13:22:17.900Z
Answers.UserDisplayName: Bryan Redeagle
Body: <p>I am building a community website that currently have two user groups but it might increase so I am trying to automate everything. The current groups are: 'teachers' &amp; 'candidates'.</p>
  
  <p>I have a channel section named 'Community' and for this channel I have setup a category group called 'Community' that has two categories named as the user groups: 'teachers' &amp; 'candidates'.</p>
  
  <p>I am trying to display a list of all the registered users in a specific group as you are loading the category template.</p>
  
  <p>This is the template that is being loaded:</p>
  
  <pre><code>{% extends "community/index" %}
  
  {% set title = category.title %}
  
  {% block main %}
  
      &lt;h1&gt;{{ category.title }}&lt;/h1&gt;
  
      {% set group = craft.users.group('{{ category.slug }}') %}
  
      {% for user in group %}
          &lt;li&gt;{{ user.name }}&lt;/li&gt;
      {% endfor %}
  
  {% endblock %} 
  </code></pre>
  
  <p>I was thinking that since the <code>{{ category.slug }}</code> has the same name as the user group, it can work but apparently not...</p>
  
  <p>Can someone help me to understand how to relate the two?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-03T19:33:20.087Z
Comments.Text: If you just output `{{ category.slug }}` onto the page, is it what you're expecting?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-03T20:03:52.310Z
Comments.Text: no, I am trying to output the all the users of the user group that has the same handle as the current category.
Comments.UserDisplayName: LessMore Creative Studio
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-03T20:05:14.127Z
Comments.Text: Right, so have you verified that `{{ category.slug }}` outputs either `teachers` or `candidates`?
Comments.UserDisplayName: Brad Bell
Tags: <categories><user-groups>
Title: User groups in relation to categories
ThreadText: # User groups in relation to categories
  
  (Asked by: username_0 on 2016-01-03)
  
  I am building a community website that currently have two user groups but it might increase so I am trying to automate everything. The current groups are: 'teachers' & 'candidates'.
  
  I have a channel section named 'Community' and for this channel I have setup a category group called 'Community' that has two categories named as the user groups: 'teachers' & 'candidates'.
  
  I am trying to display a list of all the registered users in a specific group as you are loading the category template.
  
  This is the template that is being loaded:
  
  ```
  {% extends "community/index" %}
  
  {% set title = category.title %}
  
  {% block main %}
  
      <h1>{{ category.title }}</h1>
  
      {% set group = craft.users.group('{{ category.slug }}') %}
  
      {% for user in group %}
          <li>{{ user.name }}</li>
      {% endfor %}
  
  {% endblock %} 
  
  ```
  
  I was thinking that since the `{{ category.slug }}` has the same name as the user group, it can work but apparently not...
  
  Can someone help me to understand how to relate the two?
  
  **Tags:** categories, user-groups
  
  > **Comments:**
  > **username_1**: If you just output `{{ category.slug }}` onto the page, is it what you're expecting?  
  > **username_0**: no, I am trying to output the all the users of the user group that has the same handle as the current category.  
  > **username_1**: Right, so have you verified that `{{ category.slug }}` outputs either `teachers` or `candidates`?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2016-01-04. Score: 2 | Accepted answer
  
  I believe your problem lies in the parameter for user group. In Twig, you don't need the brackets if you're already in brackets. You just reference the variable and fields directly. So instead of:
  
  ```
  {% set group = craft.users.group('{{ category.slug }}') %}
  
  ```
  
  Try this:
  
  ```
  {% set group = craft.users.group(category.slug) %}
  
  ```
  
  You see, the ElementCriteriaModel that's parsing the parameter for group doesn't run all its function arguments through Twig. So you're confusing it by throwing braces in there. Just give it the variable and field without quotes or braces and it should work smashingly, provided that `category.slug` is the same as a group `slug`.
  
  
  ---
  
  