Suspend all users apart from admin users for development copy
@chrisc is setting up a development copy of a busy Discourse site for training and testing by administrators, without sending emails to non-administrators. They considered suspending all non-administrators to achieve this.
@slackmoehrle suggested using a SQL statement to update the users table, setting silenced_till and suspended_till to a future date for non-admin users.
@pfaffman mentioned a site setting that disables mail for non-admins and also suggested configuring the site with invalid email credentials.
@chrisc successfully executed the SQL statement using psql, and also discovered a “staff only” setting for “disable emails” which is a more suitable solution.
To summarize, to disable all non-admin users:
Enter the Discourse app using ./launcher enter app
Access the PostgreSQL database using su - postgres and psql
Connect to the Discourse database using \c discourse
Execute the SQL statement: UPDATE users SET silenced_till='3019-02-01 13:00:00', suspended_till='3019-02-01 13:00:00' WHERE admin='f';
Quit psql and exit the app.
Alternatively, use the “staff only” setting for “disable emails” to achieve the same result.
I’m looking at the steps to take to create a development copy of a busy Discourse site that can be used for training and testing by administrators but which won’t send any emails to non-administrators.
Am I correct in understanding that if all non-administrators are suspended then this would have the result I’m after?
And if this would work can anyone point me in the right direction for how to do this using the rails console?
Thanks, I don’t have a huge amount of experience of using the rails console so I’m afraid I didn’t get past that first line:
[1] pry(main)> UPDATE users
NameError: undefined local variable or method `users' for main:Object
Did you mean? user_mask
from (pry):1:in `__pry__'
Any suggestions?
For the criteria would it be something like this to only edit non-admins?
WHERE not(admin: true)
Yes, I have used the option to disable all outgoing emails in the past but the plan for this site is to have a test version of a site that can send out and receive emails but only admins can use it.
discourse=# SELECT FROM users WHERE admin='t';
--
(6 rows)
And then tried:
discourse=# UPDATE users
discourse-# SET silenced_till = '3019-02-01 13:00:00,'
discourse-# SET suspended_till = '3019-02-01 13:00:00'
discourse-# WHERE admin='f'
discourse-# RETURNING id, username_lower;
ERROR: syntax error at or near "SET"
LINE 3: SET suspended_till = '3019-02-01 13:00:00'
^
However this works:
discourse=# UPDATE users
discourse-# SET silenced_till = '3019-02-01 13:00:00', suspended_till = '3019-02-01 13:00:00'
discourse-# WHERE admin='f'
discourse-# RETURNING id, username_lower;