Discourse Dynamic Groups

:information_source: Summary Automatically manage group membership
:hammer_and_wrench: Repository Link https://github.com/communiteq/discourse-dynamic-groups
:open_book: Install Guide How to install plugins in Discourse

:warning: This plugin should be considered beta :warning:

Features

Discourse communities often need to automate group memberships based on conditions like badge ownership or existing group memberships.

Common use cases include:

  • Users not in the ‘subscribers’ group

  • Users not banned from posting in Marketplace

  • Users at TL0 or TL1, but not TL2

  • Users who have completed the new user tutorial or have been members for over a year

  • Users belonging to client_1, client_2, or client_3 and are not an intern

Previously, solving this required custom scripts that periodically synchronized groups. The Dynamic Groups plugin eliminates that need.

This plugin introduces a boolean expression field to group settings, allowing administrators to define rules that dynamically determine group membership.

Examples:

  • users who are not in the ‘subscribers’ group
    trust_level_0 AND NOT subscribers

  • users who are not banned from posting in Marketplace
    trust_level_2 AND NOT banned_users

  • users who are on TL0 or TL1 but not on TL2
    trust_level_0 AND NOT trust_level_2

  • users who completed the new user tutorial or are member for over a year
    badge:certified OR badge:anniversary

  • users who belong to client 1, 2 or 3 and are not an intern
    (client_1 OR client_2 OR client_3) AND NOT interns

Configuration

Once the plugin is installed and enabled, a new tab will appear in the group admin interface:

When you enter or update the boolean expression, the system will take a few moments to populate the group with matching users. From that point on, group membership will be automatically updated as user status changes.

Important:
When a rule is defined, the group is marked as automatic, disabling manual member changes. To revert the group to manual management, simply clear the expression field. The existing members will remain, and you’ll regain manual control.

15 Likes

Wow! Awesome work, Richard!

This fills a large gap in group management within Discourse. Totally delighted, and looking forward to giving it a good run.

I’ll be primarily using it to enable functional subgroups.

1 Like

Definitely a welcome addition to Discourse’s features!

1 Like

Hi @Nathan - do you see a solution to the problem with group automation no longer working in this plugin?

Not sure what you are asking, Paul. The two are unrelated. This plugin cannot be connected to User Custom Fields at present, and I don’t think it will be on the roadmap at present.

It might be worth asking nicely for it to be a feature though as it is quite similar in many ways and I can imagine it playing nicely with the Boolean UI.

On the other side, the functionality already exists in core (albeit currently a bit broken for multiselect fields).

1 Like

OK, I guess that answers my question.
I was wondering whether this plugin might offer an alternative way to do the same thing that group automation used to do, before it broke; namely allocating users to groups based on criteria supplied. Yes, criteria involving custom user fields would be pretty essential in my case, so a show stopper if that is not possible currently.

Yeah, that’s not going to happen, it would make the plugin overly complex.