How to manually add users and email in console mode?


I setup a localhost for test discourse. When I run

./launcher enter app

to get into the docker as root

how can I add discourse users and emails like

rake admin:create



(Jens Maier) #2
rails c
u = User.create!(username: "name", email: "", password: "password")
u.approve(Discourse.system_user, false) # if manual approvals are required

If the user should be an admin, add , admin: true to the create line inside the parentheses; likewise for moderators.


Great. It is ok.


(Sam Saffron) #4

rake admin:invite is very useful for inviting admins.

(Ted Strauss) #5

Using this method, will the new user receive an invite email?
I am setting up a SSO site and I want to create accounts for all of my existing users without them receiving any email.

(Kane York) #6

Turn on the disable_email site setting before adding the users to suppress the welcome emails.

(Jared Needell) #7

Anyone have a way to script this for multiple users?

(Tony Curzon Price) #8

@Jared_Needell - I did a simple kludgey thing for multiple users:
with a csv of all my users, I put them into a google sheet and created essentially this line for each entry with a string formula:

=“u = User.create!(username: '”&B45&"’, email: ‘"&A45&"’, password: ‘xxx’, mailing_list_mode: ‘true’);u.approve(Discourse.system_user, false) ; u.activate"

I then put the strings created into a file on the server (mail-import.rb), opened the console and typed:

load ‘./mail-import.rb’

It worked a treat

(Tony Curzon Price) #9

I do have a question about email notifications using this method.

I have added users through the console using the following commands:

u = User.create!(username: 'xx', email: '', password: 'xxx', mailing_list_mode: 'true');u.approve(Discourse.system_user, false) ; u.activate

I have enabled "Send all new users a welcome message with a quick start guide" in

However, emails are not being sent to users being added in this way. They are being sent to users I add through the web front end ... (ie it's not an email problem).

I want the users I add automatically to receive the welcome email - I am migrating a googlegroup and the welcome email will be useful in moving people. So does anyone know how I can alert the system to these added users being "new" users from the point of view of receiving the welcome message?

Thank you for any help


(Allen - Watchman Monitoring) #10


@vindia has a solution here Importing Users

(Chris D) #12

This is helpful! Is there a way to assign the user(s) to groups from command?

(Sora &\) #13

we can send an invite user then copy link invite user and create user in other tab

(Nordize) #14

I successfully used Jens Maier’s solution above, but there was no welcome email … I actually wanted a welcome email. Using the latest v1.8.0.beta7 with virtually default docker installation options and emails are working fine otherwise (I get a welcome email if I send an invite from the admin panel).

Any ideas?