<p>First off, the easiest way to fetch the user's entries is to do something like this:</p>

<pre><code>{% set entries = craft.entries.authorId(user.id) %}
{% for entry in entries %}
    {{ entry.title }}
{% endfor %}
</code></pre>

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

<hr>

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

<p>First, create an empty array:</p>

<pre><code>{% set services = [] %}
</code></pre>

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

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

<p>Then we can use this array to display whatever we want on the frontend:</p>

<pre><code>{% for item in services %}
    {{ item }}
{% endfor %}
</code></pre>

<hr>

<p>So, all together:</p>

<pre><code>{% 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 %}
</code></pre>

CC BY-SA 4.0
2018-12-27T14:09:16.740Z
2018-12-27T14:16:41.737Z
2018-12-27T14:16:41.737Z
Jalen Davenport
<p>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 <code>displaying what type of entries they have posted e.g. lifestyle or tech.</code> to do this I need to get the <code>users entries</code> and query a <code>service</code> dropdown field, if they have <code>lifestyle</code> selected in multiple entries only display 1x tag showing the user has <code>lifestyle</code> posts.</p>

<p>So far I'm just trying to query each user's entries.</p>

<pre><code>{% 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 %}
</code></pre>

<entries>
Display Entries Belonging to User
# Display Entries Belonging to User

(Asked by: username_0 on 2018-12-20)

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() %}
              
          {% else %}
              
          {% endif %}

            {{ user.username }}
            {{ user.location }}
            {{ user.richText }}

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

      {% endfor %}

**Tags:** entries


---

## 1 answers

### Answer by username_1 on 2018-12-27. Score: 2 | Accepted answer

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() %}
        
    {% else %}
        
    {% endif %}

    {{ user.username }}
    {{ user.location }}
    {{ user.richText }}

    {% 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 %}


---

