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



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.


rake admin:invite is very useful for inviting admins.


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.

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


Anyone have a way to script this for multiple users?

@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


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


1 Like


@vindia has a solution here

1 Like

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

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

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?