<p>From the <a href="https://craftcms.com/docs/searching#searching-for-specific-element-attributes" rel="nofollow">Search</a> page in the docs, it looks like you can't search by author. </p>

<p>It looks, on the face of it, like entries can only be searched on Title, Slug and any of your Custom Fields.</p>

CC BY-SA 3.0
2016-03-03T16:39:20.243Z
2016-03-03T16:39:20.243Z
Steve Holland
<p>For Craft 3, at least for now.</p>
<ol>
<li><p>Make a custom plugin</p>
</li>
<li><p>Add event to modify the query in control panel</p>
<pre><code>// Register element query prepare event
Event::on(ElementQuery::class, ElementQuery::EVENT_BEFORE_PREPARE,
    function(Event $event)  {
        if (Craft::$app-&gt;getRequest()-&gt;getIsCpRequest()) {
            if ($event-&gt;sender-&gt;elementType === 'craft\elements\Entry') {

                if(isset($_POST['criteria']['search'])&amp;&amp;strpos($_POST['criteria']['search'],'author')!==false)
                {
                    $email = explode(':',$_POST['criteria']['search']);
                    if(isset($email[1]))
                    {
                        $user = User::find()-&gt;email($email[1])-&gt;one();

                        if($user)
                        {

                            $event-&gt;sender-&gt;query-&gt;andWhere(['authorId'=&gt;$user-&gt;id]);  
                            $event-&gt;sender-&gt;subQuery-&gt;andWhere(['authorId'=&gt;$user-&gt;id]);  
                            $event-&gt;sender-&gt;search = null;
                        } 
                    }

                }
            }
        }
    }
);
</code></pre>
</li>
<li><p>So when you type <code>author:[Email]</code> it can fetch in the CMS.</p>
</li>
</ol>

CC BY-SA 4.0
2020-01-09T08:52:23.950Z
2023-02-19T08:07:35.660Z
2023-02-19T08:07:35.660Z
Nickwanhere
<p>How can you filter entries in the CP by Author? I assumed entering something like <strong>author:tdavis</strong> (where tdavis is my username) would do it, but no results returned. I also tried substituting id for username.</p>

<control-panel><search><author>
Filter entries in CP by Author
# Filter entries in CP by Author

(Asked by: username_0 on 2016-03-03)

How can you filter entries in the CP by Author? I assumed entering something like **author:tdavis** (where tdavis is my username) would do it, but no results returned. I also tried substituting id for username.

**Tags:** control-panel, search, author


---

## 2 answers

### Answer by username_1 on 2016-03-03. Score: 1 | Accepted answer

From the [Search](https://craftcms.com/docs/searching#searching-for-specific-element-attributes) page in the docs, it looks like you can't search by author.

It looks, on the face of it, like entries can only be searched on Title, Slug and any of your Custom Fields.


---

### Answer by username_2 on 2020-01-09. Score: 2

For Craft 3, at least for now.

Make a custom plugin

Add event to modify the query in control panel
// Register element query prepare event
Event::on(ElementQuery::class, ElementQuery::EVENT_BEFORE_PREPARE,
    function(Event $event)  {
        if (Craft::$app->getRequest()->getIsCpRequest()) {
            if ($event->sender->elementType === 'craft\elements\Entry') {

                if(isset($_POST['criteria']['search'])&&strpos($_POST['criteria']['search'],'author')!==false)
                {
                    $email = explode(':',$_POST['criteria']['search']);
                    if(isset($email[1]))
                    {
                        $user = User::find()->email($email[1])->one();

                        if($user)
                        {

                            $event->sender->query->andWhere(['authorId'=>$user->id]);  
                            $event->sender->subQuery->andWhere(['authorId'=>$user->id]);  
                            $event->sender->search = null;
                        } 
                    }

                }
            }
        }
    }
);


So when you type author:[Email] it can fetch in the CMS.


---

