<p>A blanket <code>relatedTo</code> query should do the trick.</p>
<pre><code>craft.entries().section('thename').relatedTo(currentUser).all()
</code></pre>

CC BY-SA 4.0
2021-02-25T14:07:14.067Z
First thing I tried and no. I found https://github.com/craftcms/cms/issues/2392#issuecomment-363185158 where Brandon Kelly says author isn't stored the same as other fields.
Amanda Lutz
CC BY-SA 4.0
2021-02-25T02:12:27.827Z
2021-02-25T02:12:27.827Z
andrewmenich
<p>My project requires a notifications area. I want to list all notification entries that were created by currentUser or sent to currentUser.</p>
<p>I can do created by = <code>craft.entries().section('thename').authorId(currentUser.id).all()</code></p>
<p>I can do sent to = <code>craft.entries().section('thename').relatedTo({ targetElement: currentUser, field: 'thefield' }).all()</code></p>
<p>But is there a single query that will get both?</p>

<templating><relatedto><current-user><author>
How can I make an entries query based on currentUser is author or relatedTo currentUser
# How can I make an entries query based on currentUser is author or relatedTo currentUser

(Asked by: username_0 on 2021-02-24)

My project requires a notifications area. I want to list all notification entries that were created by currentUser or sent to currentUser.

I can do created by = `craft.entries().section('thename').authorId(currentUser.id).all()`

I can do sent to = `craft.entries().section('thename').relatedTo({ targetElement: currentUser, field: 'thefield' }).all()`

But is there a single query that will get both?

**Tags:** templating, relatedto, current-user, author


---

## 1 answers

### Answer by username_1 on 2021-02-25. Score: 1

A blanket relatedTo query should do the trick.
craft.entries().section('thename').relatedTo(currentUser).all()

> **Comments:**
> **username_0**: First thing I tried and no. I found https://github.com/craftcms/cms/issues/2392#issuecomment-363185158 where Brandon Kelly says author isn't stored the same as other fields.  

---

