<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>

CC BY-SA 3.0
2017-12-22T14:36:42.793Z
Thanks I did mess with the value indeed. 
Your suggestion pointed me in the right direction.
Milksamsa
CC BY-SA 3.0
2017-12-22T14:43:29.213Z
Were you able to solve the issue?
Robin Schambach
CC BY-SA 3.0
2017-12-22T19:40:10.787Z
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.
Milksamsa
CC BY-SA 3.0
2017-12-22T19:45:51.277Z
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
Robin Schambach
CC BY-SA 3.0
2017-12-22T13:51:55.000Z
2017-12-22T13:51:55.000Z
2020-06-17T08:56:27.903Z
Robin Schambach
<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>

<templating><categories><users><relations><search>
One select search for Users in user.group
# 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:

    Professionalità
    {% for category in craft.categories.group('professionalita') %}
    {{ category.title }}
    {% endfor %}


This is what I tried to build on results.html page.
{# 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 %}
        
            {% for member in members %}
                {{ member.firstName }}
            {% endfor %}
        
    {% 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. 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
{{ category.title }}

What you have to do is:
{{ category.title }}

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  

---

