# Bulk delete suspended users after import

**URL:** https://meta.discourse.org/t/bulk-delete-suspended-users-after-import/73011
**Category:** Support
**Created:** [10월 29, 2017, 5:53오후 UTC](https://meta.discourse.org/t/bulk-delete-suspended-users-after-import/73011 "2017-10-29T17:53:32Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![omarfilip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/omarfilip/32/208019_2.png) [@omarfilip](https://meta.discourse.org/u/omarfilip)
#### Post date: [10월 29, 2017, 5:53오후 UTC](https://meta.discourse.org/t/bulk-delete-suspended-users-after-import/73011/1 "2017-10-29T17:53:32Z")

</div>

After converting a phpBB forum, I have ~700 suspended users. I’d like to delete the ones that also have no posts or topics.

Is there a rails command for that?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [10월 29, 2017, 8:48오후 UTC](https://meta.discourse.org/t/bulk-delete-suspended-users-after-import/73011/2 "2017-10-29T20:48:12Z")

</div>

Sure @vinothkannans can advise you on this.

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [10월 30, 2017, 2:52오전 UTC](https://meta.discourse.org/t/bulk-delete-suspended-users-after-import/73011/3 "2017-10-30T02:52:30Z")

</div>

For that, you should enter into the container with

```shell
./launcher enter app

```

Then, you will need to launch the [rails console](http://guides.rubyonrails.org/command_line.html#rails-console) with

```shell
rails c

```

Once you’re in the rails console, you can delete all suspended users who have zero posts and topics with

```ruby
User.joins(:user_stat).where("users.suspended_at IS NOT NULL AND user_stats.topic_count = 0 AND user_stats.post_count = 0").destroy_all

```

_Always make sure you have latest db backup whenever you run `destroy_all` method._

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [12월 14, 2019, 1:57오후 UTC](https://meta.discourse.org/t/bulk-delete-suspended-users-after-import/73011/4 "2019-12-14T13:57:24Z")

</div>



---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [1월 13, 2020, 2:03오후 UTC](https://meta.discourse.org/t/bulk-delete-suspended-users-after-import/73011/5 "2020-01-13T14:03:14Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
