# How to manually add users and email in console mode?

**URL:** https://meta.discourse.org/t/how-to-manually-add-users-and-email-in-console-mode/26669
**Category:** Support
**Created:** [23 مارس 2015، 2:16م UTC](https://meta.discourse.org/t/how-to-manually-add-users-and-email-in-console-mode/26669 "2015-03-23T14:16:43Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![doudou](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@doudou](https://meta.discourse.org/u/doudou)
#### Post date: [23 مارس 2015، 2:16م UTC](https://meta.discourse.org/t/how-to-manually-add-users-and-email-in-console-mode/26669/1 "2015-03-23T14:16:44Z")

</div>

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`

?

Thanks.

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [23 مارس 2015، 3:25م UTC](https://meta.discourse.org/t/how-to-manually-add-users-and-email-in-console-mode/26669/2 "2015-03-23T15:25:53Z")

</div>

```ruby
rails c
u = User.create!(username: "name", email: "name@email.com", password: "password")
u.approve(Discourse.system_user, false) # if manual approvals are required
u.activate

```

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

---

<div class="post-metadata">

### Author: ![doudou](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@doudou](https://meta.discourse.org/u/doudou)
#### Post date: [23 مارس 2015، 3:42م UTC](https://meta.discourse.org/t/how-to-manually-add-users-and-email-in-console-mode/26669/3 "2015-03-23T15:42:49Z")

</div>

Great. It is ok.

Thanks

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [23 مارس 2015، 10:51م UTC](https://meta.discourse.org/t/how-to-manually-add-users-and-email-in-console-mode/26669/4 "2015-03-23T22:51:38Z")

</div>

`rake admin:invite` is very useful for inviting admins.

---

<div class="post-metadata">

### Author: ![trudat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/trudat/32/104354_2.png) [@trudat](https://meta.discourse.org/u/trudat)
#### Post date: [30 يونيو 2015، 8:54م UTC](https://meta.discourse.org/t/how-to-manually-add-users-and-email-in-console-mode/26669/5 "2015-06-30T20:54:49Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [1 يوليو 2015، 12:22ص UTC](https://meta.discourse.org/t/how-to-manually-add-users-and-email-in-console-mode/26669/6 "2015-07-01T00:22:27Z")

</div>

Turn on the disable\_email site setting before adding the users to suppress the welcome emails.

---

<div class="post-metadata">

### Author: ![Jared\_Needell](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jared_needell/32/116554_2.png) [@Jared\_Needell](https://meta.discourse.org/u/Jared_Needell)
#### Post date: [27 أغسطس 2015، 7:48م UTC](https://meta.discourse.org/t/how-to-manually-add-users-and-email-in-console-mode/26669/7 "2015-08-27T19:48:32Z")

</div>

Anyone have a way to script this for multiple users?

---

<div class="post-metadata">

### Author: ![tonycurzonprice](https://avatars.discourse-cdn.com/v4/letter/t/73ab20/32.png) [@tonycurzonprice](https://meta.discourse.org/u/tonycurzonprice)
#### Post date: [27 أغسطس 2015، 9:12م UTC](https://meta.discourse.org/t/how-to-manually-add-users-and-email-in-console-mode/26669/8 "2015-08-27T21:12:52Z")

</div>

@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

---

<div class="post-metadata">

### Author: ![tonycurzonprice](https://avatars.discourse-cdn.com/v4/letter/t/73ab20/32.png) [@tonycurzonprice](https://meta.discourse.org/u/tonycurzonprice)
#### Post date: [27 أغسطس 2015، 9:19م UTC](https://meta.discourse.org/t/how-to-manually-add-users-and-email-in-console-mode/26669/9 "2015-08-27T21:19:27Z")

</div>

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: ‘xx@xx.com’, 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 [http://forum.brickfield.org.uk/admin/site\_settings/category/uncategorized](http://forum.brickfield.org.uk/admin/site_settings/category/uncategorized)

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

Tony

---

<div class="post-metadata">

### Author: ![optimus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/optimus/32/39715_2.png) [@optimus](https://meta.discourse.org/u/optimus)
#### Post date: [13 يناير 2016، 4:23م UTC](https://meta.discourse.org/t/how-to-manually-add-users-and-email-in-console-mode/26669/12 "2016-01-13T16:23:57Z")

</div>

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

---

<div class="post-metadata">

### Author: ![thaidb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thaidb/32/68488_2.png) [@thaidb](https://meta.discourse.org/u/thaidb)
#### Post date: [5 مارس 2017، 7:07ص UTC](https://meta.discourse.org/t/how-to-manually-add-users-and-email-in-console-mode/26669/13 "2017-03-05T07:07:09Z")

</div>

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

---

<div class="post-metadata">

### Author: ![nordize](https://avatars.discourse-cdn.com/v4/letter/n/c68b51/32.png) [@nordize](https://meta.discourse.org/u/nordize)
#### Post date: [17 مارس 2017، 4:07ص UTC](https://meta.discourse.org/t/how-to-manually-add-users-and-email-in-console-mode/26669/14 "2017-03-17T04:07:50Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [15 مايو 2019، 1:11م UTC](https://meta.discourse.org/t/how-to-manually-add-users-and-email-in-console-mode/26669/15 "2019-05-15T13:11:50Z")

</div>



---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [15 مايو 2019، 1:25م UTC](https://meta.discourse.org/t/how-to-manually-add-users-and-email-in-console-mode/26669/16 "2019-05-15T13:25:53Z")

</div>


