Is it possible to bulk activate pending users with the rails console?

I guess all is in the title, but I have an additional question.
Is there a list of Discourse rails commands somewhere? I remember seeing one, but I won’t find it.

1 Like

Probably, but I don’t think this is good practice because you might end up spamming out emails to unverified addresses.

myInactiveUsers = User.where(active: false)

myInactiveUsers.each do |myInactiveUser|
  myInactiveUser.active = true
  myInactiveUser.save!
end

The above script should work, but I’m not sure if there would be additional unintended side-effects (functionally), use at your own risk!

This is just Active Record Basics — Ruby on Rails Guides

And knowing the basic objects that Discourse maintains, in this case the User model.

The models are here: https://github.com/discourse/discourse/tree/master/app/models

6 Likes

Thanks for the reply :slight_smile:
It’s just out of curiosity after reading this thread.

I won’t test the code myself and since you’re not sure that were won’t be any side-effect, I can’t check the solution button.

Thanks for the links!

3 Likes

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