Partial read-only mode

Every now and then we come across a situation where a forum needs to be in “read only” mode in order to prevent new posts being made.

However, it is really annoying that read only mode also prevents configuration changes, SSO synchronization and logging in.

It would be great if we had some kind of partial read only mode where only posts and post actions would be read-only.

Right now the only thing I can think of is stripping post permissions from all category security groups but that is a bit too hacky and it requires storing them somewhere else for the time being.

Does anyone have an idea on what the best way to accomplish this would be?
Probably this is plugin territory, but still: what approach would be best?

12 Likes

A plugin + site setting should do the trick.

Maybe try the validate_post hook, add a custom validation that returns “no good” if the site setting sets it to readonly.

6 Likes

I used NewPostManager.add_handler, it seems like the :validate_post event only notifies and does not present the opportunity to return a result and deny the post.

Here’s a plugin which disables posting with the flick of a button: GitHub - communiteq/discourse-prevent-posting

Configuration

Go to Admin - Plugins - discourse-prevent-posting - Settings

prevent posting enabled : enable the plugin and prevent new posts from being made.

prevent posting message : message to show as global notice when the plugin is enabled.

prevent posting allow pms : if enabled, PM’s are allowed.

7 Likes

I think we should add this to our roadmap @sam

7 Likes

Sure!

Though I would like to nail down the setting here, ideally we can fit it all into a single site setting with multiple options.

Would like to first get a good spec going. Some questions:

  • What about reactions and plugins?
  • What about user profiles?
  • What about signing up with new accounts?

I worry also about allowing too much fidelity here.

Maybe a simple maintenance mode on/off and allowing admins always to bypass, is good enough?

7 Likes

FYI/FWIW -

For our community, this plugin provides a “Sabbath” mode. The heart behind it is to prompt community members to take what they’ve experienced in our online context and lovingly serve their neighbors in their local communities.

The key components behind what Richard developed are:

  • The ability to schedule both routine and occasional times when posting is disabled and turned back on. There’s the ability to disable posting for weekends (ongoing) and also for major holidays (occasional).

  • The capacity to sync this with a custom Global Banner so we don’t confuse participants (“why is the site not working?!”). Rather, we can clearly explain to visitors and members why posting is temporarily disabled.

As for other activity:

  • Disabling reactions is congruent with the original vision but I suppose could be a checkbox admins could toggle in order to expand the versatility of this site setting

  • I don’t think this plugin affects any other plugins

  • New accounts can be created - only posting is disabled

It works beautifully. I’m excited that this capacity might be integrated into the roadmap.

3 Likes

@outofthebox Actually the scheduling is not part of this plugin, that’s the scheduled-readonly plugin which works closely together with the prevent-posting plugin.

5 Likes

I stand corrected! :slight_smile:

4 Likes

I’m so glad to know this, as I’ve been experimenting with the idea of a Sabbath or vacation mode, as I may want us to take time away, especially if I’m running my Discourse site along with a class.

I think I’ll try both plugins, thank you!

EDIT: I’ve just tested this out and got it working on one of my sites, but when I went to edit the plugin to turn it off, it said it was in read-only mode and I couldn’t edit the setting. I tried clicking the “disable read-only mode” in the Admin > Backups but I think the plugin was overriding the setting.

Once the plugin is enabled and is in the read-only time period, is there any way for me to disable it?

EDIT 2: I had to rebuild without the plugin, as it got stuck and enforced read-only mode even after the time had expired. I don’t know if me manually clicking the “disable read-only mode” button caused that. Also, for some reason, the holiday period wasn’t even enabling on another Discourse instance, so I’m left baffled :slight_smile:

2 Likes

Something similar to the OP is now possible.

We recently added a “staff writes only” mode - it’s a readonly mode that only affects non-staff. It allows staff to login, post, change settings, etc, while other users see a site that is effectively in readonly mode.

Usage

To enable, from the console, run:

Discourse.enable_readonly_mode(Discourse::STAFF_WRITES_ONLY_MODE_KEY)

and to disable:

Discourse.disable_readonly_mode(Discourse::STAFF_WRITES_ONLY_MODE_KEY)

I hope this is useful to you! Let me know if you have any questions.

13 Likes

Is there any chance of implementing ADMIN_WRITES_ONLY_MODE_KEY to also prevent moderation actions?

I have a use case scenario where I put the forum in read only mode, perform backup and then keep the forum online and accessible for viewing while the new vps is being rebuilt from scratch, backup restored and than IP switched to the new server seamlessly without downtime.

Any moderation actions on the old server post backup/read only mode would be lost after the live switch if moderators are exempt from partial readonly mode.

I’m currently using a full readonly mode, but it is cumbersome because it also prevents admin changes using the Web UI.

3 Likes

This topic was automatically closed after 13 days. New replies are no longer allowed.

Now that this has been added, is there any plan to add this as an option to the scheduled read only plugin?

3 Likes

Good idea. I’ll put that on my list of fun projects and in the meanwhile PR’s are welcome as well :slight_smile:

3 Likes

Just a heads up for anyone testing the scheduled read-only plugin, I put a test case for about 2 minutes and it confused me why it wasn’t turning off—turns out it only checks every 5 minutes.

2 Likes