# Modify trust level for all users

**URL:** https://meta.discourse.org/t/modify-trust-level-for-all-users/103628
**Category:** Self-Hosting
**Tags:** trust-levels, how-to
**Created:** [March 9, 2016, 8:58am UTC](https://meta.discourse.org/t/modify-trust-level-for-all-users/103628 "2016-03-09T08:58:35Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [March 9, 2016, 8:58am UTC](https://meta.discourse.org/t/modify-trust-level-for-all-users/103628/1 "2016-03-09T08:58:35Z")

</div>

Here’s an example of a [bulk operation](https://meta.discourse.org/t/administrative-bulk-operations/118349) to set the trust level to 2 for all users currently at trust level 0 or 1:

This is slow, but properly triggers all side effects (group membership updates, badge grants, and logging). It may be preferred especially when you have fewer than 1000 users. Note: this does not skip users with manually locked trust levels — add `.where(manual_locked_trust_level: nil)` to the query if you want to skip them.

```ruby
User.where(trust_level: [0, 1]).find_each do |user|
   user.change_trust_level!(TrustLevel[2])
end

```

If there were more than 1000 users, I would have used this instead, but this bypasses all side effects (group updates, badges, logging) and does not respect locked trust levels.

```ruby
DB.exec("UPDATE users SET trust_level = 2 WHERE trust_level IN (0, 1)")

```

> Last edited by @southpaw 2025-01-29T15:02:09Z
> 
> > **Check document**
> >
> > Perform check on document:
