I maintain an employee forum where we want to disable access to specific users without emailing them. The way we have been disabling access is by suspending their account. When we suspend their account the user receives an email containing the reason for suspension. We’d really rather not bother the person with an email.
I’ve tried first deactivating a test account before suspending it, but an email is still sent.
Note: when I suspend a user, I am not filing in the “Email message” field with anything.
Is there a way I can disable access to Discourse without emailing the user?
Here’s some code that will do it at the rails console:
./launcher enter app
rails c
username = "user-to-suspend-username"
admin_username = "admin-username"
reason = "suspend reason"
till = Time.at(33174889200)
u = User.find_by_username(username)
puts "couldn't find user named #{username}" unless u
if u and !u.suspended?
u.suspended_till = till
u.suspended_at = DateTime.now
User.transaction do
u.save!
admin = User.find_by_username(admin_username)
StaffActionLogger.new(admin).log_user_suspend(
u,
reason
)
end
u.logged_out
end
I know how to do that at the Rails console, but is there a way to do that in Web UI? I see the option to edit their email in their profile, but it looks like it requires the email to be verified before it takes effect.
You’re right, I just tested that. And deactivating the user’s email doesn’t prevent the email from going out either. I could have sworn that no email was sent unless the optional message was added in past versions.