Here’s some plugin code that will trigger automatic group membership for anon users on account creation or login:
# frozen_string_literal: true
# name: CfAnonSchedule
# about: Regularly add anon accounts to a group
# version: 0.1
# authors: xertrov
# url: https://github.com/xertrov
register_asset 'stylesheets/desktop/cf-anon-schedule.scss', :desktop
register_asset 'stylesheets/mobile/cf-anon-schedule.scss', :mobile
PLUGIN_NAME ||= 'CfAnonSchedule'
load File.expand_path('lib/cf-anon-schedule/engine.rb', __dir__)
[:users_created, :user_logged_in].each do |event|
DiscourseEvent.on(event) do |user|
There’s a bit more to it than that (a settings.yaml file with the enabled setting), but otherwise it’s just the default plugin that gets generated via
rails g plugin. I can polish it up a bit (like removing scss stuff) and push to a github repo if there’s interest in using it.
I have only done some basic, manual tests w/ it, but it seems to work for both logging in with an existing anon user + on the creation of a new anon user.
Edit: I initially planned to do like a scheduled thing, but this seems more elegant.
Edit2: it presumes you have the
group > membership > automatic setting configured.