How to disable access without emailing user


My forum is on version 2.7.0.beta6.

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?

- Ryan


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 =
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 =

  User.transaction do!
    admin = User.find_by_username(admin_username)
1 Like

If the person is no longer an employee, how are they still able to access their corporate email account? :thinking:

You could always edit the user first, change their email to no@email.some.random.nonexistent.domain

And then suspend them.

1 Like

It uses personal emails.

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.

1 Like

Wasn’t the emailing optional before?


All the documentation makes it look that way! But, it sends an email even if you leave the message part blank.{id}~1suspend.json/put

Will send an email with this message when present

Optionally, provide more information about the suspension and it will be emailed to the user


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.


I’ve started a pull request to bring behavior in line with documentation:


This fix has been merged by @eviltrout :tada:


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