The original poster, ryantm, is looking for a way to disable access to specific users on their employee forum without sending them an email notification. Currently, when an account is suspended, an email is sent to the user, even if the “Email message” field is left blank.
ryantm provided a workaround using the Rails console, but was hoping to find a solution through the Web UI. Richie suggested editing the user’s email to a non-existent domain before suspending them, but ryantm noted that this would require verification.
omarfilip mentioned that emailing used to be optional, but testing revealed that an email is still sent even when the message field is blank. ryantm created a pull request to fix this issue, which has since been merged by eviltrout.
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.