Answers.Body: <p>This should do it:</p>
  
  <pre><code>{# Grab all the entries for the section #}
  {% set entries = craft.entries.section('news').find() %}
  
  {# Group by the authorId #}
  {% set entriesByAuthor = entries|group('authorId') %}
  
  {# Grab all of the users with the userIds in entriesByAuthor #}
  {% set authors = craft.users.id(entriesByAuthor|keys) %}
  
  &lt;ul&gt;
      {% for author in authors %}
          &lt;li&gt;{{ author.username }}
      {%  endfor %}
  &lt;/ul&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-21T14:42:17.077Z
Answers.Text: Awesome, thanks as always!! Why doesn't it work with the usual relatedTo parameter?
Answers.UserDisplayName: Alan Miller
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-21T04:40:44.997Z
Answers.LastActivityDate: 2018-01-29T17:51:14.637Z
Answers.LastEditDate: 2018-01-29T17:51:14.637Z
Answers.UserDisplayName: Brad Bell
Answers.Body: <p>This is similar to <a href="https://craftcms.stackexchange.com/questions/1345/check-to-see-if-category-is-populated">another question</a>, and should yield the same results:</p>
  
  <pre><code>{% set entryIds = craft.entries.section('news').ids() %}
  {% set authorList = craft.users.relatedTo({ sourceElement: entryIds }).find() %}
  </code></pre>
  
  <p>With this you are basically saying, "I'm looking for users related to these news entries where the news entry is where the user is set".</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-24T13:07:24.353Z
Answers.Text: I tried a version like that previously and I also just tested the snippet above and it isn't working : ( That is definitely how I would expect it to work... that's why I thought maybe there was something I was missing.
Answers.UserDisplayName: Alan Miller
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-04T03:53:39.983Z
Answers.Text: This only works with a user relationship field on the entry, or a entries relationship field on the user. This does not work for the Author field on entries.
Answers.UserDisplayName: Johan Douma
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-24T12:53:38.853Z
Answers.LastActivityDate: 2014-07-24T12:53:38.853Z
Answers.LastEditDate: 2017-04-13T12:51:00.303Z
Answers.UserDisplayName: Bryan Redeagle
Body: <p>I am trying to show a list of users but only if they have created a post in a certain section... the code I am using isn't working as expected. Perhaps I have the syntax wrong when it comes to the user model</p>
  
  <p>Help would be greatly appreciated.</p>
  
  <pre><code>{% set entries = craft.entries.section('news') %}
  {% set authorList = craft.users.relatedTo(entries) %}
  
  {% for author in authorList %}
  &lt;h5&gt;&lt;a href="/news/author/{{author.username}}"&gt;{{author.fullName}}&lt;/a&gt;&lt;/h5&gt;
  {% endfor %}         
  </code></pre>
  
Tags: <users>
Title: Author List, Only Users With Entry
ThreadText: # Author List, Only Users With Entry
  
  (Asked by: username_0 on 2014-07-24)
  
  I am trying to show a list of users but only if they have created a post in a certain section... the code I am using isn't working as expected. Perhaps I have the syntax wrong when it comes to the user model
  
  Help would be greatly appreciated.
  
  ```
  {% set entries = craft.entries.section('news') %}
  {% set authorList = craft.users.relatedTo(entries) %}
  
  {% for author in authorList %}
  <h5><a href="/news/author/{{author.username}}">{{author.fullName}}</a></h5>
  {% endfor %}         
  
  ```
  
  **Tags:** users
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2014-08-21. Score: 2 | Accepted answer
  
  This should do it:
  
  ```
  {# Grab all the entries for the section #}
  {% set entries = craft.entries.section('news').find() %}
  
  {# Group by the authorId #}
  {% set entriesByAuthor = entries|group('authorId') %}
  
  {# Grab all of the users with the userIds in entriesByAuthor #}
  {% set authors = craft.users.id(entriesByAuthor|keys) %}
  
  <ul>
      {% for author in authors %}
          <li>{{ author.username }}
      {%  endfor %}
  </ul>
  
  ```
  
  > **Comments:**
  > **username_0**: Awesome, thanks as always!! Why doesn't it work with the usual relatedTo parameter?  
  
  ---
  
  ### Answer by username_2 on 2014-07-24. Score: 1
  
  This is similar to [another question](https://craftcms.stackexchange.com/questions/1345/check-to-see-if-category-is-populated), and should yield the same results:
  
  ```
  {% set entryIds = craft.entries.section('news').ids() %}
  {% set authorList = craft.users.relatedTo({ sourceElement: entryIds }).find() %}
  
  ```
  
  With this you are basically saying, "I'm looking for users related to these news entries where the news entry is where the user is set".
  
  > **Comments:**
  > **username_0**: I tried a version like that previously and I also just tested the snippet above and it isn't working : ( That is definitely how I would expect it to work... that's why I thought maybe there was something I was missing.  
  > **username_3**: This only works with a user relationship field on the entry, or a entries relationship field on the user. This does not work for the Author field on entries.  
  
  ---
  
  