Answers.Body: <p>You could get the IDs of all users belonging to a group, and use these IDs prefixed with <code>not</code> as the <code>id</code> parameter in a second <code>craft.users</code> ElementCriteriaModel:</p>
  
  <pre><code>{% set userIds = craft.users.group('group1, group2, group3').ids() %}
  {% set users = craft.users.id('and, not ' ~ userIds|join(', not ')) %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-25T14:17:26.947Z
Answers.LastActivityDate: 2014-11-25T14:28:58.423Z
Answers.LastEditDate: 2014-11-25T14:28:58.423Z
Answers.UserDisplayName: carlcs
Answers.Body: <p>I don't think it's possible, exactly for the reasons you provide: while other criteria accept 'not X', group and groupId explicitly add andWhere criteria with the Ids found with ids or handles.</p>
  
  <p>You could make a plugin that returns an array containing all users without a user group, but maybe that's a bit far fetched. I do think that's the only way (for now), if you don't want to do it post retrieving ...</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-24T22:25:59.633Z
Answers.LastActivityDate: 2014-11-24T22:25:59.633Z
Answers.UserDisplayName: Paul
Body: <p>I'm struggling to find a way to use <code>craft.users</code> to select all users that are not members of any groups. Looking at the User Element Type both the <code>groupId</code> and <code>group</code> parameters are used to perform additional queries which will return nothing unless a valid group Id or handle is provided... I think.</p>
  
  <p>Is it possible to find users not in groups or will I have to do this post retrieving all users... I need to paginate the results so this is not ideal.</p>
  
Tags: <templating><users><user-groups>
Title: How can I select users that are not members of any user groups?
ThreadText: # How can I select users that are not members of any user groups?
  
  (Asked by: username_0 on 2014-11-24)
  
  I'm struggling to find a way to use `craft.users` to select all users that are not members of any groups. Looking at the User Element Type both the `groupId` and `group` parameters are used to perform additional queries which will return nothing unless a valid group Id or handle is provided... I think.
  
  Is it possible to find users not in groups or will I have to do this post retrieving all users... I need to paginate the results so this is not ideal.
  
  **Tags:** templating, users, user-groups
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2014-11-25. Score: 3
  
  You could get the IDs of all users belonging to a group, and use these IDs prefixed with `not` as the `id` parameter in a second `craft.users` ElementCriteriaModel:
  
  ```
  {% set userIds = craft.users.group('group1, group2, group3').ids() %}
  {% set users = craft.users.id('and, not ' ~ userIds|join(', not ')) %}
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2014-11-24. Score: 2
  
  I don't think it's possible, exactly for the reasons you provide: while other criteria accept 'not X', group and groupId explicitly add andWhere criteria with the Ids found with ids or handles.
  
  You could make a plugin that returns an array containing all users without a user group, but maybe that's a bit far fetched. I do think that's the only way (for now), if you don't want to do it post retrieving ...
  
  
  ---
  
  