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

(Barry van Oudtshoorn) #1

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:
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/users.rb at master · discourse/discourse_api · GitHub – 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?

(Barry van Oudtshoorn) #2

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

(Sam Saffron) #3

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

(Barry van Oudtshoorn) #4

Worked like a charm – thanks muchly @sam!