<p>If you want to delete users (or any other elements in Craft) directly from the database, the place to do that is the <code>elements</code> table. Delete the row(s) from there, and all the elements’ rows in the other tables will go away automatically.</p>

CC BY-SA 3.0
2014-10-21T06:18:06.110Z
I want to delete a lot of "pending" users. I can't see where in craft_elements what is what. There isn't a column to differentiate them from "active" users?
Simon Clayson
CC BY-SA 3.0
2014-10-24T08:40:43.090Z
Not to worry, purgePendingUsersDuration seems to work great!
Simon Clayson
CC BY-SA 4.0
2020-03-16T01:33:37.547Z
Is this still the case for 2020? Table `elements` or `elements_sites`. `craft_elements` does not exist.
Jessica Talzor
CC BY-SA 4.0
2020-03-16T02:27:38.650Z
@JessicaTalzor still valid, yes. You should definitely have an `elements` table (possibly prefixed with something depending on your `tablePrefix` setting).
Brandon Kelly
CC BY-SA 4.0
2024-02-14T12:04:00.557Z
For anybody wondering, this still works in 2024!
Jamie Jenkins
CC BY-SA 4.0
2014-07-16T22:59:48.573Z
2020-03-16T02:26:59.230Z
2020-03-16T02:26:59.230Z
Brandon Kelly
<p>We have a client site that has been getting a lot of spam registrations. We're turning on <a href="http://buildwithcraft.com/docs/config-settings#purgePendingUsersDuration"><code>purgePendingUsersDuration</code></a> to help deal  with some of these automatically, but I was planning to go into the database to delete a bunch in bulk directly (since there are almost 200 of them)</p>

<p>Is it safe to delete them just from <code>craft_users</code> and <code>craft_usergroups_users</code> tables? Are there other places I should watch out for?</p>

<users><database>
Is it safe to mass delete users from the database directly
# Is it safe to mass delete users from the database directly

(Asked by: username_0 on 2014-07-16)

We have a client site that has been getting a lot of spam registrations. We're turning on [`purgePendingUsersDuration`](http://buildwithcraft.com/docs/config-settings#purgePendingUsersDuration) to help deal with some of these automatically, but I was planning to go into the database to delete a bunch in bulk directly (since there are almost 200 of them)

Is it safe to delete them just from `craft_users` and `craft_usergroups_users` tables? Are there other places I should watch out for?

**Tags:** users, database

---

## 1 answers

### Answer by username_1 on 2014-07-16. Score: 9 | Accepted answer

If you want to delete users (or any other elements in Craft) directly from the database, the place to do that is the `elements` table. Delete the row(s) from there, and all the elements’ rows in the other tables will go away automatically.

> **Comments:**
> **username_2**: I want to delete a lot of "pending" users. I can't see where in craft_elements what is what. There isn't a column to differentiate them from "active" users?  
> **username_2**: Not to worry, purgePendingUsersDuration seems to work great!  
> **username_3**: Is this still the case for 2020? Table `elements` or `elements_sites`. `craft_elements` does not exist.  
> **username_1**: @JessicaTalzor still valid, yes. You should definitely have an `elements` table (possibly prefixed with something depending on your `tablePrefix` setting).  
> **username_4**: For anybody wondering, this still works in 2024!  

---

