# Unique code for user to register

**URL:** https://meta.discourse.org/t/unique-code-for-user-to-register/106491
**Category:** Development
**Created:** [January 14, 2019, 12:57pm UTC](https://meta.discourse.org/t/unique-code-for-user-to-register/106491 "2019-01-14T12:57:35Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![guiqis](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/guiqis/32/129006_2.png) [@guiqis](https://meta.discourse.org/u/guiqis)
#### Post date: [January 14, 2019, 12:57pm UTC](https://meta.discourse.org/t/unique-code-for-user-to-register/106491/1 "2019-01-14T12:57:35Z")

</div>

Is it possible to have an unique code from another application (like those purchase codes that people use to activate softwares and support) for the users to register?

I’m using discourse as an exclusive forum for users who have purchased my product. So I would like to make the registration process easier, by asking them to put their transaction code (that I can get via api) in the registration form.

Does anyone know a plugin or code for that? (Or even if it’s possible?)

---

<div class="post-metadata">

### Author: ![vulkanino](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vulkanino/32/119654_2.png) [@vulkanino](https://meta.discourse.org/u/vulkanino)
#### Post date: [January 14, 2019, 1:10pm UTC](https://meta.discourse.org/t/unique-code-for-user-to-register/106491/2 "2019-01-14T13:10:52Z")

</div>

What if you send your customer an invite, and maybe link him with a special group?

---

<div class="post-metadata">

### Author: ![guiqis](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/guiqis/32/129006_2.png) [@guiqis](https://meta.discourse.org/u/guiqis)
#### Post date: [January 14, 2019, 2:03pm UTC](https://meta.discourse.org/t/unique-code-for-user-to-register/106491/3 "2019-01-14T14:03:17Z")

</div>

That’s what I’m doing right now, but my product has sales every day. So it’s complicated for me to send those bulk invitations every day, or every week. Not complicated, but it would be better to have the option that I’ve mentioned

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [January 14, 2019, 2:48pm UTC](https://meta.discourse.org/t/unique-code-for-user-to-register/106491/4 "2019-01-14T14:48:02Z")

</div>

Are you sending the invitations by hand?

If so, you could instead have your sales backend send an API call to Discourse that generates the invite and sends it to the user.

If you don’t want to have this happen on every purchase, you could also put a page on your site that verifies the transaction ID and calls the invite API.

This might be a more straightforward approach than a plugin.

---

<div class="post-metadata">

### Author: ![guiqis](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/guiqis/32/129006_2.png) [@guiqis](https://meta.discourse.org/u/guiqis)
#### Post date: [January 14, 2019, 3:09pm UTC](https://meta.discourse.org/t/unique-code-for-user-to-register/106491/5 "2019-01-14T15:09:28Z")

</div>

It seems awesome both of the options. If they’re possible I can hire a developer. The point is that I’m not sure if an API like this would work with discourse. If so, that would be amazing.

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [January 14, 2019, 3:18pm UTC](https://meta.discourse.org/t/unique-code-for-user-to-register/106491/6 "2019-01-14T15:18:33Z")

</div>

> [@guiqis](#):
>
> The point is that I’m not sure if an API like this would work with discourse.

The great thing is that because of the nature of the Discourse application all of the actions are available via the API, since that is what the web interface is calling.

Here are the relevant API calls you might use in your scenario:

- [Invite a user by email to join your forum](https://docs.discourse.org/#tag/Invites%2Fpaths%2F~1invites%2Fpost)
- [Generate an invite link but don’t send an email](https://docs.discourse.org/#tag/Invites%2Fpaths%2F~1invites~1link%2Fpost)
