<p>Try this:</p>
<pre><code>{% set entries = craft.entries.section('movementCoursesEntries').level(1).relatedTo({
   targetElement: currentUser,
   field: 'permittedUsers'
}).ids() | join(', not ') %}

{% set unrelated = craft.entries.section('movementCoursesEntries').level(1).id('and, not '~entries).all() %}

{% for entry in unrelated %}
    {{ entry.title }}
{% endfor %}
</code></pre>

CC BY-SA 4.0
2020-08-03T11:05:05.537Z
Thank you! Works like a charm!
LessMore Creative Studio
CC BY-SA 4.0
2020-08-03T12:19:51.780Z
@LessandMoreCollective Glad to help you!
Pavel Pavlovich
CC BY-SA 4.0
2020-08-03T07:47:59.993Z
2020-08-03T07:47:59.993Z
Pavel Pavlovich
<p>I am trying to get all the entries that don't related to the current user via a user field.
<br>
I have used the following code to fetch all the entries that do related to the current user
<br></p>
<pre><code>{% set entries = craft.entries.section('movementCoursesEntries').level(1).relatedTo({
   targetElement: currentUser,
   field: 'permittedUsers'
}).find() %} 
</code></pre>
<p>When I try to exclude these entries from the rest of the entries in the structure, I get nothing</p>
<pre><code>{% set unrelated = craft.entries.section('movementCoursesEntries').level(1)|without(entries) %}

{% for entry in unrelated %}
    {{ entry.title }}
{% endfor %}
</code></pre>
<p>Any idea how to filter those entries properly?
Thank you!</p>

<relations><current-user><exclude>
Get entries that aren't related to current user
# Get entries that aren't related to current user

(Asked by: username_0 on 2020-08-02)

I am trying to get all the entries that don't related to the current user via a user field.

I have used the following code to fetch all the entries that do related to the current user

{% set entries = craft.entries.section('movementCoursesEntries').level(1).relatedTo({
   targetElement: currentUser,
   field: 'permittedUsers'
}).find() %} 

When I try to exclude these entries from the rest of the entries in the structure, I get nothing
{% set unrelated = craft.entries.section('movementCoursesEntries').level(1)|without(entries) %}

{% for entry in unrelated %}
    {{ entry.title }}
{% endfor %}

Any idea how to filter those entries properly?
Thank you!

**Tags:** relations, current-user, exclude

---

## 1 answers

### Answer by username_1 on 2020-08-03. Score: 0 | Accepted answer

Try this:
{% set entries = craft.entries.section('movementCoursesEntries').level(1).relatedTo({
   targetElement: currentUser,
   field: 'permittedUsers'
}).ids() | join(', not ') %}

{% set unrelated = craft.entries.section('movementCoursesEntries').level(1).id('and, not '~entries).all() %}

{% for entry in unrelated %}
    {{ entry.title }}
{% endfor %}

> **Comments:**
> **username_0**: Thank you! Works like a charm!  
> **username_1**: @LessandMoreCollective Glad to help you!  

---

