Answers.Body: <p>I suggest you to read the docs about <a href="https://craftcms.com/docs/relations#the-relatedTo-param" rel="nofollow noreferrer">relations</a>. You can search for relations by the following parameter</p>
  <blockquote>
  <p>In its simplest form, you can pass in one of these things to it:</p>
  <p>An AssetFileModel, CategoryModel, EntryModel, UserModel, or TagModel object</p>
  <p>An element’s ID</p>
  <p>An array of element objects and/or IDs</p>
  </blockquote>
  <p>What you pass is a string or to be more specific a url</p>
  <pre><code>&lt;option value=&quot;{{category.url}}&quot;&gt;{{ category.title }}&lt;/option&gt;
  </code></pre>
  <p>What you have to do is:</p>
  <pre><code>&lt;option value=&quot;{{category.id}}&quot;&gt;{{ category.title }}&lt;/option&gt;
  </code></pre>
  <p>In order to find users related to a category id.</p>
  <p>However I strongly suggest you to build your search with PHP if you are going to include multiple parameters (more categories/search terms/complex and+or bindings) it is going to be a mess with twig</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-22T14:36:42.793Z
Answers.Text: Thanks I did mess with the value indeed. 
  Your suggestion pointed me in the right direction.
Answers.UserDisplayName: Milksamsa
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-22T14:43:29.213Z
Answers.Text: Were you able to solve the issue?
Answers.UserDisplayName: Robin Schambach
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-22T19:40:10.787Z
Answers.Text: Yes I did… now I'm struggling with something different… a double http:// http:// domain.dev when calling {{ image.member }}. Craft can be daunting at beginning I guess.
Answers.UserDisplayName: Milksamsa
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-22T19:45:51.277Z
Answers.Text: Well. The only difficulty is to understand the difference between an object and an array. As soon as you know that craft becomes really easy but most questions on this board are about that topic. Not sure what your member field is and why it should contain a url - you should only work with URLs in the `getUrl()` function - but you could create a new question or we can open a chat for further discussions/questions. Btw please have a look at this topic https://craftcms.stackexchange.com/a/23193/5557
Answers.UserDisplayName: Robin Schambach
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-22T13:51:55.000Z
Answers.LastActivityDate: 2017-12-22T13:51:55.000Z
Answers.LastEditDate: 2020-06-17T08:56:27.903Z
Answers.UserDisplayName: Robin Schambach
Body: <p>I'm a complete newby on Craft CMS and twig templating so please bear with me.</p>
  
  <p>I currently have a users base which I want to filter by category (a custom field)</p>
  
  <p>This would be my only input search element:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;select name="professionalita"&gt;
      &lt;option value="" disabled selected&gt;Professionalità&lt;/option&gt;
      {% for category in craft.categories.group('professionalita') %}
      &lt;option value="{{category.url}}"&gt;{{ category.title }}&lt;/option&gt;
      {% endfor %}
  &lt;/select&gt;
  </code></pre>
  
  <p>This is what I tried to build on results.html page.</p>
  
  <pre class="lang-twig prettyprint-override"><code>{# Get the search data #}
  {% set profParam = craft.request.getParam('professionalita') %}
  
  {% extends "_inc/layout" %}
  
  {% block main %}
      {# Find and list matching entries #}
      {% set members = craft.users.group.('members').relatedTo(profParam) %}
  
      {% if members|length %}
          &lt;ul&gt;
              {% for member in members %}
                  &lt;li&gt;{{ member.firstName }}&lt;/li&gt;
              {% endfor %}
          &lt;/ul&gt;
      {% else %}
          No members found.
      {% endif %}
  {% endblock %}
  </code></pre>
  
  <p>I get no results even if there are actually correspondencies between the users and the category name being searched for.</p>
  
Tags: <templating><categories><users><relations><search>
Title: One select search for Users in user.group
ThreadText: # One select search for Users in user.group
  
  (Asked by: username_0 on 2017-12-22)
  
  I'm a complete newby on Craft CMS and twig templating so please bear with me.
  
  I currently have a users base which I want to filter by category (a custom field)
  
  This would be my only input search element:
  
  ```html
  <select name="professionalita">
      <option value="" disabled selected>Professionalità</option>
      {% for category in craft.categories.group('professionalita') %}
      <option value="{{category.url}}">{{ category.title }}</option>
      {% endfor %}
  </select>
  
  ```
  
  This is what I tried to build on results.html page.
  
  ```twig
  {# Get the search data #}
  {% set profParam = craft.request.getParam('professionalita') %}
  
  {% extends "_inc/layout" %}
  
  {% block main %}
      {# Find and list matching entries #}
      {% set members = craft.users.group.('members').relatedTo(profParam) %}
  
      {% if members|length %}
          <ul>
              {% for member in members %}
                  <li>{{ member.firstName }}</li>
              {% endfor %}
          </ul>
      {% else %}
          No members found.
      {% endif %}
  {% endblock %}
  
  ```
  
  I get no results even if there are actually correspondencies between the users and the category name being searched for.
  
  **Tags:** templating, categories, users, relations, search
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-12-22. Score: 1 | Accepted answer
  
  I suggest you to read the docs about [relations](https://craftcms.com/docs/relations#the-relatedTo-param). You can search for relations by the following parameter
  
  > In its simplest form, you can pass in one of these things to it:
  >
  > An AssetFileModel, CategoryModel, EntryModel, UserModel, or TagModel object
  >
  > An element’s ID
  >
  > An array of element objects and/or IDs
  
  What you pass is a string or to be more specific a url
  
  ```
  <option value="{{category.url}}">{{ category.title }}</option>
  
  ```
  
  What you have to do is:
  
  ```
  <option value="{{category.id}}">{{ category.title }}</option>
  
  ```
  
  In order to find users related to a category id.
  
  However I strongly suggest you to build your search with PHP if you are going to include multiple parameters (more categories/search terms/complex and+or bindings) it is going to be a mess with twig
  
  > **Comments:**
  > **username_0**: Thanks I did mess with the value indeed.  Your suggestion pointed me in the right direction.  
  > **username_1**: Were you able to solve the issue?  
  > **username_0**: Yes I did… now I'm struggling with something different… a double http:// http:// domain.dev when calling {{ image.member }}. Craft can be daunting at beginning I guess.  
  > **username_1**: Well. The only difficulty is to understand the difference between an object and an array. As soon as you know that craft becomes really easy but most questions on this board are about that topic. Not sure what your member field is and why it should contain a url - you should only work with URLs in the `getUrl()` function - but you could create a new question or we can open a chat for further discussions/questions. Btw please have a look at this topic https://craftcms.stackexchange.com/a/23193/5557  
  
  ---
  
  