The discussion explores how to implement expiring user accounts or membership renewals in Discourse, specifically for users joining via invitation links. Willy asks if such a feature exists natively or if it can be achieved via plugins without modifying core code. pfaffman suggests a standard approach: adding users to a specific group upon registration and using a custom plugin with a scheduled job to remove them from the group after a set period, storing expiration data in user custom fields.
When Willy asks for specific plugin recommendations, pfaffman clarifies that no such plugin exists and must be written, though alternatives like using the Data Explorer plugin combined with external automation tools (e.g., Zapier) might work for non-self-hosted instances. tobiaseigen identifies this as a good candidate for community-contributed automation scripts. Willy expresses interest in developing this further, proposing a system where invitation links carry key-value data that is merged into the user’s profile upon registration, and asks if this could be merged into core Discourse.
tobiaseigen notes that invitation links are indeed always unique but encourages Willy to develop the plugin first, referencing the Development category and developer documentation for guidance. Core inclusion is possible only if the feature proves widely useful.
Later, pfaffman shares a Ruby code snippet implementing a scheduled job that removes users from a group if their membership date is older than one month, validating the concept. Adam_Root confirms the approach is viable without core modifications, providing code examples for setting expiration dates via custom fields and removing users from groups. Finally, mcwumbly points out that the newer Discourse Workflows feature now supports this logic natively, potentially eliminating the need for custom plugins entirely.
Every time a user registers with an invitation link, I would like that account to only last x months and once the deadline has reached the user must renew their account, is it possible to do so?
It is basically a membership with an expiration date and renewal. If this feature does not exist in Discourse, is it possible to program it through a plugin or something similar without touching the core? or is there no support in the API and webhooks for something like this?
You’d add them to a group when they joined. You’d then have a plugin that removed them from the group after the time limit was up. Just how you’d keep up with the month isn’t clear. Probably a user custom field with the end date would be the most simple.
“You’d then have a plugin that removed them from the group after the time limit was up.” which plugin?
“Probably a user custom field with the end date would be the most simple.” Do I add that information during signup? Then I should use a webhook at that point, correct?
There is no such plugin. Someone would need to write it.
No. The plugin would do that. And it’s likely that there’s a way to discern when they got added via the database and data explorer, though I’m not really sure.
If you’re not self hosted, or for other reason don’t want a plugin,
It might also be possible to hack something together using the data explorer plugin (to get data on when they were added and hence, should be deleted) and use an automation/api tool (like zapier, though I’ve also used github actions) to remove them from the group when the time comes.
This would be a nice candidate for an automation script! Does not exist yet so you could contribute it or hire someone to do it for you and contribute it, in Marketplace.
I can do that, but with an extra feature: it should allow key-value fields to be added.
The idea is that I can associate information with an invitation link with the information I want. The values can be a simple string or a JSON, and each key is a column in the database. Then, when the user finishes registering, an extra key-value pair is added, which is their username.
My question is, will it pass your filters and be added to the native Discourse source code? And this leads me to an additional question, are invitation links always unique?
I slipped this topic across to Development because we are moving out of support territory here. You need to just get going with creating the plugin or automation that does what you want. Let us know how you get on! If the features you add are more widely useful, they may be considered for inclusion eventually in core Discourse.
You can also start more topics in Development to ask more questions, but I do recommend you have code to share as you do so. It is easier for others to help you if they can see what you’ve done so far.
Yes, invitation links are always unique.
I don’t know what you mean by “pass your filters and be added to the native Discourse source code”.
These are the types of questions I think you will be able to find out for yourself as you dig into the code.