# Bulk remove users

**URL:** <https://meta.discourse.org/t/bulk-remove-users/53450>\
**Category:** Product Support\
**Created:** [November 27, 2016, 10:32pm UTC](https://meta.discourse.org/t/bulk-remove-users/53450 "2016-11-27T22:32:00Z")\
**Posts on this page:** 1\
**Showing post:** 16

<div class="post-metadata">

**Author:** ![leonardo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leonardo/32/228634_2.png) [@leonardo](https://meta.discourse.org/u/leonardo)\
**Post date:** [January 13, 2023, 2:27pm UTC](https://meta.discourse.org/t/bulk-remove-users/53450/16 "2023-01-13T14:27:23Z")

</div>

Note: nowadays there is a specific class for destroying Users and associated records cleanly: `UserDestroyer`.

So instead of this:

> [@zogstrip](#):
>
> ```ruby
> User.where(post_count: 0).destroy_all
> 
> ```

This should be done:

```ruby
destroyer = UserDestroyer.new(Discourse.system_user)
User.joins(:user_stat).where("user_stats.post_count = 0").each { |u| destroyer.destroy(u) }

```

---

_[View the full topic](https://meta.discourse.org/t/bulk-remove-users/53450)._
