Discourse User Importer
This script will create users for a Discourse installation given a CSV file with users.
🚨Deprecation Warning 🚨
Please be aware that this script is quite old and Discourse has evolved since then. If you want to add users to your Discourse installation automatically, please check out the following options:
There are a few different programs that help automate the process using the API. For example:
As well as various helpful threads on the Discourse forum:
Thanks to @safisher for these tips
Some features include:
- Password is automatically generated, but your users need to reset it
- Imported users are automatically approved by the system user (
- Imported users are automatically granted
trust_level: 1permissions, just like invited users
- Users can be automatically assigned to one or more predefined groups
- If a user already exists, but has new groups in the CSV-file, these groups will be automatically added to the existing user
- Special task to check if usernames already exist
- Error handling may be a little rough. Please check beforehand if all data in your CSV-file is correct, e.g. that the groups you want to use already exist.
Import file format
|Yes||The email address of the user|
||Yes||The user's full name|
||No||The user's user name. If none is supplied, this will be generated from the email address.|
||No||The user's title, e.g. Vice President of Engineering|
||No||A comma separated list of groups a user should be added to. When left empty, the user will not be added to any specific groups.|
For each user a random password is generated using
are able to set their own password after importing by using the password reset
function in Discourse.
Add this file to your
lib/tasks and run one of the following tasks:
To check if one or more usernames already exists, without importing:
$ rake user_importer:check[/path/to/users.csv]
To import all the users in the file:
$ rake user_importer:import[/path/to/users.csv]
After running this script
Since users are automatically approved, they can log in right away after running this script. Because the user's password is an automatically generated random string, a newly imported user can only log in by generating a new password through the password reset function in Discourse. They will then receive a link to set a new password in their email.