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

(Xgdgsc) #1

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!

(Jay Pfaffman) #2

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.

(Mittineague) #3

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.

(Jay Pfaffman) #4

Hmm. I guess I’m not.

(Xgdgsc) #5

So it is not possible for now?

(Jay Pfaffman) #6

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.

(Xgdgsc) #7

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

(Xgdgsc) #8

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

(Mittineague) #9

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.

(Xgdgsc) #10

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

(Mittineague) #11

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