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!
AI-generated summary
In a discussion about creating a plugin to grant group access based on user activity, xgdgsc asks if it’s possible to automatically assign users to private groups after meeting post-count criteria in a category. pfaffman initially suggests using custom badges, but Mittineague clarifies that badge criteria do not automatically grant group membership. pfaffman confirms this limitation. xgdgsc asks if it’s currently impossible, and pfaffman confirms: no built-in mechanism exists — a custom plugin or external program using the API is needed. xgdgsc inquires about “group query,” misunderstanding it as a simple API call; Mittineague explains that “group query” would be a UI feature (like badge queries) to run scheduled SQL to auto-assign groups — risky due to potential performance issues, and not currently available. xgdgsc accepts a plugin without UI and asks how to schedule it. Mittineague recommends integrating with Discourse’s Jobs module, pointing to @david’s plugin as an example. The consensus is: while not natively supported, a custom plugin with hardcoded queries and scheduled jobs via the Jobs API is feasible.
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 https://meta.discourse.org/groups/search.json 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