# Bulk suspend users based on criteria

**URL:** https://meta.discourse.org/t/bulk-suspend-users-based-on-criteria/76804
**Category:** Support
**Created:** [December 27, 2017, 8:06am UTC](https://meta.discourse.org/t/bulk-suspend-users-based-on-criteria/76804 "2017-12-27T08:06:27Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [December 27, 2017, 4:00pm UTC](https://meta.discourse.org/t/bulk-suspend-users-based-on-criteria/76804/4 "2017-12-27T16:00:00Z")

</div>

If you would like to use the rails console to bulk suspend users, something like this should do the trick:

```plaintext
suspend_till = DateTime.new(2057,1,1)
users = User.where(last_seen_at: nil, id: 1..Float::INFINITY, admin: false)
users.each do |u|
  u.suspended_till = suspend_till
  u.suspended_at = DateTime.now
  u.save!
end

```

---

_[View the full topic](https://meta.discourse.org/t/bulk-suspend-users-based-on-criteria/76804)._
