So you want to generate multiple Invite Links? Great! Let’s get started!
Clone Discourse API Gem
If you already have Git and Ruby installed on your system, you can install Discourse API by running following command from console:
git clone https://github.com/discourse/discourse_api.git ~/discourse_api
Generate Master API Key
Generate Master API Key for your Discourse instance by visiting
/admin/api, to interact with Discourse API.
Generate multiple Invite Tokens
Now that you have cloned Discourse API gem and generated master API key, let’s start generating invite tokens!
discourse_api/examples/disposable_invite_tokens.rb file, and modify following information:
- Provide API credentials:
client = DiscourseApi::Client.new("http://localhost:3000") client.api_key = "YOUR_API_KEY" client.api_username = "YOUR_USERNAME"
http://localhost:3000 with the url of your discourse instance, eg:
YOUR_API_KEY with the master API key of your discourse instance, eg:
YOUR_USERNAME with the Admin username of your discourse instance, eg:
- Provide Invites details:
invite_tokens = client.disposable_tokens(username: "eviltrout", quantity: 200 , group_names: "security,support")
eviltrout with the username of person whose account you want to be attached with generated invites.
200 with the quantity of tokens you want to generate.
group_names parameter is optional. If you want invited users to be automatically added to specific group(s), specify the group names separated with comma. eg:
Now in console, from
discourse_api directory run:
This command will generate a
invite_tokens.csv file inside
invite_tokens.csv file and voilà it will have 100 invite tokens ready to be used instantly!
Prepare Invitation Links from Invite Token
The Invitation URL will be like:
Replace following fields:
discourse.example.comwith the URL of your Discourse instance.
TOKENwith one of the 200 Invite tokens you just generated.
USERNAMEwith the desired username of invited user
NAMEwith the first name of invited user
TOPICwith the id of the topic to direct the user to after joining
(*) these fields are required!
[Note that we use Percent-encoding in URL, so
space needs to be specified as
+ needs to be specified as
Visit Invitation Link
When the user will visit Invitation Link, he will be registered, activated and logged in instantly. If you specified the groups while generating tokens, he will be automatically added to that particular group(s) when logged in.
That’s it! Start generating Invite Links for your Discourse instance today!
Update: Now you can generate Invite links via UI!
To generate copyable invite link go to your invites page, click on “Send an Invite” button, enter the email of the user you want to invite, now click on “Copy Invite Link” button:
That’s it, now you will see copyable invite link:
Copy and paste away! :link: