Is it possible to set an expiration date for user accounts?

AI-generated summary

In a discussion titled “Is it possible to set an expiration date for user accounts?” in the Dev category, Willy asks if it’s possible to automatically expire user accounts after a set period (e.g., x months) following registration via an invitation link, requiring renewal. pfaffman suggests using a group and a custom plugin to remove users after expiration, noting that no such plugin currently exists and that user metadata could be tracked via the database or Data Explorer. Willy follows up asking which plugin and whether signup-time data should be added manually — pfaffman clarifies that the plugin would handle it automatically. tobiaseigen proposes this as a good candidate for an automation script and encourages contribution to the community. Willy adds a feature request: allowing key-value fields (including JSON) to be associated with invitation links, to store custom metadata per user. tobiaseigen moves the topic to Development, advising Willy to begin developing the plugin or automation script, pointing to developer documentation and encouraging code-sharing as progress is made. He notes that broadly useful features may eventually be considered for inclusion in core Discourse.

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.

Refer to Documentation > Developer Guides and #community-wiki:developers for guidance on creating plugins.

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.