Answers.Body: <p>Iterating on Michael's answer: build an array of users to exclude, like this:</p>
  
  <pre><code>{% set excludeArray = null %}
  {% for user in entry.winners_exclude %}
      {% if loop.first %}{% set excludeArray = ['and'] %}{% endif %} {# only set this array if exclude users exist #}
      {% set excludeArray = excludeArray |merge(['not ' ~ user.id]) %}
  {% endfor %}
  
  {# check if users should be excluded, I'm not sure what happens if you'd do .author(null) #}
  {% if excludeUsers %}
      {% paginate craft.entries.section('bildupload').author(excludeUsers) %}
  {% else %}
      {% paginate craft.entries.section('bildupload') %}
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-15T05:36:48.757Z
Answers.Text: Good job writing out the needed twig code :)
Answers.UserDisplayName: mrsmn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-14T09:20:50.967Z
Answers.LastActivityDate: 2017-09-14T09:20:50.967Z
Answers.UserDisplayName: Paul
Answers.Body: <p>Have you tried building your excluded list like this <code>['and', 'not user1', 'not user2']</code> ? </p>
  
  <p>Because I know syntax like that works for excluding sections in search results. Below is how I excluded certain sections from search results. </p>
  
  <pre><code> {% paginate craft.entries.section(['and', 'not services', 'not solutions']).search(query).limit(settings.postsPerPage) as pageInfo, entries %} 
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-14T08:49:39.253Z
Answers.Text: Thing is: I don't know which users need to be excluded beforehand. So I would need to somehow iterate over the array.
Answers.UserDisplayName: justussimon91
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-14T08:53:14.240Z
Answers.Text: it should be possible to loop over your `exclude_users` array and build one that  is formatted like that... I'll have a go at it soonish :)
Answers.UserDisplayName: mrsmn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-14T08:46:51.140Z
Answers.LastActivityDate: 2017-09-14T08:46:51.140Z
Answers.UserDisplayName: mrsmn
Body: <p>I'm trying to get a list of entries of a certain section, however I'd like to exclude certain users that are defined within a field of the entry.</p>
  
  <p>The users to exclude from the query are fetched like so:</p>
  
  <pre><code>{% set exclude_users = entry.winners_exclude %}
  </code></pre>
  
  <p>Now, what I'm trying to do is to exclude the users in the<code>exclude_users</code>-array from being returned with the query results, something like the following (which does obviously not work, but you might get the idea of what I'm trying:</p>
  
  <pre><code>{% for entry in craft.entries.section('bildupload').author(not in exclude_users).search('challengeId:' ~ch.id).order('likecounter desc').limit(3).with(['useruploads']) %}
  </code></pre>
  
  <p>Specifically I'm talking about the <code>.author(not in exclude_users)</code> part.</p>
  
  <p>I didn't really find anything on the question if that is at all possible within the elementCriteriaModel query itself. It works with an additional if-condition within the for-loop, however since the elementCriteriaModel needs to be <code>.limit</code>(ed) to 3 but needs to exclude some users, excluding them within the loop after limiting the result to the first 3 results obviously results not in what I want, since it will just exclude the users from the first 3 results.</p>
  
Tags: <search><elementcriteriamodel><filter>
Title: Exclude entries by array of authors from ElementCriteriaModel
ThreadText: # Exclude entries by array of authors from ElementCriteriaModel
  
  (Asked by: username_0 on 2017-09-14)
  
  I'm trying to get a list of entries of a certain section, however I'd like to exclude certain users that are defined within a field of the entry.
  
  The users to exclude from the query are fetched like so:
  
  ```
  {% set exclude_users = entry.winners_exclude %}
  
  ```
  
  Now, what I'm trying to do is to exclude the users in the`exclude_users`-array from being returned with the query results, something like the following (which does obviously not work, but you might get the idea of what I'm trying:
  
  ```
  {% for entry in craft.entries.section('bildupload').author(not in exclude_users).search('challengeId:' ~ch.id).order('likecounter desc').limit(3).with(['useruploads']) %}
  
  ```
  
  Specifically I'm talking about the `.author(not in exclude_users)` part.
  
  I didn't really find anything on the question if that is at all possible within the elementCriteriaModel query itself. It works with an additional if-condition within the for-loop, however since the elementCriteriaModel needs to be `.limit`(ed) to 3 but needs to exclude some users, excluding them within the loop after limiting the result to the first 3 results obviously results not in what I want, since it will just exclude the users from the first 3 results.
  
  **Tags:** search, elementcriteriamodel, filter
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2017-09-14. Score: 2
  
  Iterating on Michael's answer: build an array of users to exclude, like this:
  
  ```
  {% set excludeArray = null %}
  {% for user in entry.winners_exclude %}
      {% if loop.first %}{% set excludeArray = ['and'] %}{% endif %} {# only set this array if exclude users exist #}
      {% set excludeArray = excludeArray |merge(['not ' ~ user.id]) %}
  {% endfor %}
  
  {# check if users should be excluded, I'm not sure what happens if you'd do .author(null) #}
  {% if excludeUsers %}
      {% paginate craft.entries.section('bildupload').author(excludeUsers) %}
  {% else %}
      {% paginate craft.entries.section('bildupload') %}
  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_2**: Good job writing out the needed twig code :)  
  
  ---
  
  ### Answer by username_2 on 2017-09-14. Score: 1
  
  Have you tried building your excluded list like this `['and', 'not user1', 'not user2']` ?
  
  Because I know syntax like that works for excluding sections in search results. Below is how I excluded certain sections from search results.
  
  ```
   {% paginate craft.entries.section(['and', 'not services', 'not solutions']).search(query).limit(settings.postsPerPage) as pageInfo, entries %} 
  
  ```
  
  > **Comments:**
  > **username_0**: Thing is: I don't know which users need to be excluded beforehand. So I would need to somehow iterate over the array.  
  > **username_2**: it should be possible to loop over your `exclude_users` array and build one that  is formatted like that... I'll have a go at it soonish :)  
  
  ---
  
  