Display Entries Belonging to User I'm trying to group entries by user on my front-end. I've got so far but I can't seem to get any further to my goal of displaying what type of entries they have posted e.g. lifestyle or tech. to do this I need to get the users entries and query a service dropdown field, if they have lifestyle selected in multiple entries only display 1x tag showing the user has lifestyle posts.

So far I'm just trying to query each user's entries.

{% set listings = craft.entries.section('listings') %}
{% set users = craft.users.group('influencer').all() %}


      {% for user in users %}

          {% if user.getPhoto() %}
              &lt;img class="img-fluid rounded-circle" src="{{ user.getPhoto().getUrl('thumbnail') }}"&gt;
          {% else %}
              &lt;img class="img-fluid rounded-circle" src="{{ url('images/user-ph.png') }}"&gt;
          {% endif %}

            &lt;h5 class="card-title"&gt;{{ user.username }}&lt;/h5&gt;
            &lt;small&gt;{{ user.location }}&lt;/small&gt;
            &lt;p class="card-text"&gt;{{ user.richText }}&lt;/p&gt;

        {% for user, entries in craft.entries.find() | group('users') %}
          {% for entry in entries %}
            {{ entry.title }}
          {% endfor %}
        {% endfor %}

      {% endfor %}
First off, the easiest way to fetch the user's entries is to do something like this:

{% set entries = craft.entries.authorId(user.id) %}
{% for entry in entries %}
    {{ entry.title }}
{% endfor %}


The way this works is you fetch all the entries that were authored by the current user in your main for loop by using authorId(user.id). In my opinion, this is a lot cleaner and more performant over what you were trying to accomplish with the  group filter.



Now, to answer your question; here's how I would solve it.

First, create an empty array:

{% set services = [] %}


Then, inside your user's entries for loop, we'd grab the value of the service field (for each entry) and see if it exists in the services array. If not, we'll merge it in.

{% set dropdown = entry.service.label %}
{% if dropdown not in services %}
     {% set services = services | merge([ dropdown ]) %}
{% endif %}


Then we can use this array to display whatever we want on the frontend:

{% for item in services %}
    {{ item }}
{% endfor %}




So, all together:

{% set users = craft.users.group('influencer').all() %}

{% for user in users %}

    {% if user.getPhoto() %}
        &lt;img class="img-fluid rounded-circle" src="{{ user.getPhoto().getUrl('thumbnail') }}"&gt;
    {% else %}
        &lt;img class="img-fluid rounded-circle" src="{{ url('images/user-ph.png') }}"&gt;
    {% endif %}

    &lt;h5 class="card-title"&gt;{{ user.username }}&lt;/h5&gt;
    &lt;small&gt;{{ user.location }}&lt;/small&gt;
    &lt;p class="card-text"&gt;{{ user.richText }}&lt;/p&gt;

    {% set entries = craft.entries.authorId(user.id) %}
    {% set services = [] %}
    {% for entry in entries %}
        {% set dropdown = entry.services.label %}
        {% if dropdown not in services %}
            {% set services = services | merge([ dropdown ]) %}
        {% endif %}
    {% endfor %}

    {% for item in services %}
        {{ item }}
    {% endfor %}

{% endfor %}