Listing authenticated users without roles

1st Jul
2008

Sometimes we'd like to list users who have registered with a Drupal site, but haven't been placed into any proper roles yet via subscriptions, purchases, membership approval or whatever.

Try this join query to get started:

  1. SELECT users.uid, name, created, access, login, status
  2. FROM {users}
  3. LEFT OUTER JOIN {users_roles}
  4. ON users.uid = users_roles.uid
  5. WHERE users_roles.uid IS NULL AND users.uid != 0

Post new comment

The content of this field is kept private and will not be shown publicly.