# Approve all existing users en-masse to facilitate enabling "must approve users"

**URL:** https://meta.discourse.org/t/approve-all-existing-users-en-masse-to-facilitate-enabling-must-approve-users/52689
**Category:** Support
**Created:** [9 november 2016 om 00:25 UTC](https://meta.discourse.org/t/approve-all-existing-users-en-masse-to-facilitate-enabling-must-approve-users/52689 "2016-11-09T00:25:29Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![barryvan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/barryvan/32/82635_2.png) [@barryvan](https://meta.discourse.org/u/barryvan)
#### Post date: [9 november 2016 om 00:25 UTC](https://meta.discourse.org/t/approve-all-existing-users-en-masse-to-facilitate-enabling-must-approve-users/52689/1 "2016-11-09T00:25:29Z")

</div>

So far, I’ve been running our forum in invite-only mode – which is great. I’d now like to start opening it up a little bit more, such that I can send people to the address to sign up, but require approval of their accounts before they gain access. The “must approve users” setting’s warning is making me a little leery of enabling it, though.

In reading through recent posts here on meta, it looks like:

- Invited users are _not_ considered “approved” by default.
- If I enable this flag, and use the UI to approve each user, they _won’t_ receive “your account has been approved” emails.

What I’d really like to do is approve all the users currently in the system en-masse, and then flip the switch. (I would really, really prefer not to manually approve each user, as I have 140 at the moment.) A couple of questions related to this:

- Can I simply do this by updating the database:

```sql
update users set
  approved = true, approved_by_id = 1, approved_at = current_timestamp
where not approved and active

```

- Is it better to do this via the API? I can’t seem to find an “approve” `def` in [discourse\_api/lib/discourse\_api/api/users.rb at main · discourse/discourse\_api · GitHub](https://github.com/discourse/discourse_api/blob/master/lib/discourse_api/api/users.rb) – just “activate”, which I believe is a different thing altogether.
- Will invited users subsequently be approved by default? Does this vary according to the trust level of the person inviting them?

---

<div class="post-metadata">

### Author: ![barryvan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/barryvan/32/82635_2.png) [@barryvan](https://meta.discourse.org/u/barryvan)
#### Post date: [17 november 2016 om 01:18 UTC](https://meta.discourse.org/t/approve-all-existing-users-en-masse-to-facilitate-enabling-must-approve-users/52689/2 "2016-11-17T01:18:38Z")

</div>

Does anyone have any insights on this? I’m loathe to just do something without a better understanding of how it all works… 😕 I’m happy to go spelunking through the Discourse code for approval if someone can point me in the right direction. 🙂

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [17 november 2016 om 02:00 UTC](https://meta.discourse.org/t/approve-all-existing-users-en-masse-to-facilitate-enabling-must-approve-users/52689/3 "2016-11-17T02:00:14Z")

</div>

> [@barryvan](#):
>
> update users set  
> approved = true, approved\_by\_id = 1, approved\_at = current\_timestamp  
> where not approved and active

That should, in theory do the trick, as always try on a backup first.

---

<div class="post-metadata">

### Author: ![barryvan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/barryvan/32/82635_2.png) [@barryvan](https://meta.discourse.org/u/barryvan)
#### Post date: [21 november 2016 om 01:04 UTC](https://meta.discourse.org/t/approve-all-existing-users-en-masse-to-facilitate-enabling-must-approve-users/52689/4 "2016-11-21T01:04:00Z")

</div>

Worked like a charm – thanks muchly @sam!

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [8 juni 2024 om 12:45 UTC](https://meta.discourse.org/t/approve-all-existing-users-en-masse-to-facilitate-enabling-must-approve-users/52689/5 "2024-06-08T12:45:07Z")

</div>

This topic was automatically closed after 2768 days. New replies are no longer allowed.
