<p>You probably have to query twice, first get all the users and then get all news entries
published by any of these users using the <a href="http://buildwithcraft.com/docs/templating/craft.entries#authorId" rel="nofollow"><code>authorId</code></a> parameter on your criteria model.</p>

<pre><code>{% set userRegion = currentUser.region.first() %}
{% set regionUsersIds = craft.users.relatedTo(userRegion).limit(null).ids() %}

{% set regionNews = craft.entries.section('news').authorId(regionUsersIds) %}
</code></pre>

CC BY-SA 3.0
2015-08-30T03:06:19.427Z
Genius! :D This idea arise in my head too when I woke this morning! :) Testing now... Tell you...
migmaker
CC BY-SA 3.0
2015-08-30T04:13:34.463Z
Worked like a charm :D Thx!
migmaker
CC BY-SA 3.0
2015-08-29T08:07:32.070Z
2015-08-29T08:07:32.070Z
carlcs
<p>I got a list of entries <code>news</code> (channel type).<br>
They are created by <code>users</code> (or <code>author</code>).<br>
These users have a category <code>region</code> assigned to them.  </p>

<p>My point is to list the <code>news</code> entries that have the same <code>author's category</code> than the <code>currentUser's category</code>...</p>

<p>I am trying with relatedTo but I am stuck here:   </p>

<pre><code>{% if currentUser %}
    {% set userRegion = currentUser.region.first() %}
{% endif %}

{% set regionNews = craft.entries.section('news').relatedTo('and',
    { sourceElement: currentUser, field: 'unepRegion' },
    { targetElement: author, field: 'unepRegion' }
) %}
</code></pre>

<p>Really don't know where I am going with this.</p>

<entries><categories><author>
Get entries filtered by author's category
# Get entries filtered by author's category

(Asked by: username_0 on 2015-08-28)

I got a list of entries news (channel type).
They are created by users (or author).
These users have a category region assigned to them.  
My point is to list the news entries that have the same author's category than the currentUser's category...
I am trying with relatedTo but I am stuck here:   
{% if currentUser %}
    {% set userRegion = currentUser.region.first() %}
{% endif %}

{% set regionNews = craft.entries.section('news').relatedTo('and',
    { sourceElement: currentUser, field: 'unepRegion' },
    { targetElement: author, field: 'unepRegion' }
) %}

Really don't know where I am going with this.

**Tags:** entries, categories, author

---

## 1 answers

### Answer by username_1 on 2015-08-29. Score: 2 | Accepted answer

You probably have to query twice, first get all the users and then get all news entries
published by any of these users using the authorId parameter on your criteria model.
{% set userRegion = currentUser.region.first() %}
{% set regionUsersIds = craft.users.relatedTo(userRegion).limit(null).ids() %}

{% set regionNews = craft.entries.section('news').authorId(regionUsersIds) %}

> **Comments:**
> **username_0**: Genius! :D This idea arise in my head too when I woke this morning! :) Testing now... Tell you...  
> **username_0**: Worked like a charm :D Thx!  

---

