Can I create a plugin that checks users and grant access to group based on activity?

Sorry if I post in the wrong category. I’ m new to discourse plugin development. I looked through the api doc. I wonder is it possible to run a program periodically to count how many posts a user posted in a category (which is for new users to show their ability) and grant access to some private groups after this checking. I’ m wondering if there is some plugin similar. Thanks!

You can do that with custom badges. The feature is now turned off by default, but if you’re self hosted you can turn it on.

Are you certain? The last time I looked it was more like
“meet criteria -> Badge granted”
“meet criteria -> TL group joined -> TL Badge granted”
but not
“meet criteria -> Badge granted -> custom group joined”

I’ve often thought a “group query” feature would be nice, but as troublesome as the badge query feature can be, perhaps it wouldn’t be the best idea.


Hmm. I guess I’m not.

So it is not possible for now?

It looks like @Mittineague was right and there is no mechanism for automatically adding badge-earners to a group. You will need a custom plugin or an external program to manage the groups via the API.

What do you mean by group query? Isn’ t get what you want?

Writing a custom plugin is exactly what I want to do. I’ m wondering if there is some user activity statistics api?

For custom Badges, when the ability to do so is enabled, queries can be put together and they will be routinely run, automatically granting / revoking Badges. Because a poorly written query can cause much pain, the ability requires some dev know how. Although Badges are under Admin, not all Admins are devs.

A similar feature for Groups would be a convenient UI, but would also present the same risks the Badge query UI presents.

A plugin that did not have a UI would be hacky but easier to write. The plugin could have the query(s) hard-coded and then there would need to be a way to have it run on schedule.


A plugin without a UI would be adequate for me. What do you use to run such thing on schedule?

I’ve not tried it myself, but this plugin by @david ties in to the Jobs module