Create a user with username generated from email

(Simon Cossar) #1

Using rake admin:create I can create a user by only supplying an email address and a password. The username seems to be automatically created by splitting the email address at the @ symbol. If the username already exits a number is appended to the username to make it unique.

Is it possible to get the same functionality through the Discourse API?

I’m creating a ticketing system using Discourse. Users make their initial query from my site’s homepage. I’m trying to avoid requiring them to generate unique usernames.

Discourse as a private email support portal
Discourse as a private email support portal
Create new user through API using Zapier - Webhooks
(Simon Cossar) #2

I’m still curious about this, but I’m not going to use it in my project.

(Kane York) #3

It’s the UserNameSuggester class:

It’s also used when you sign up with certain login providers, I believe?

Used heavily in imports.

(Erlend Sogge Heggen) #4

Would love a feature like this! See some relevant brainstorming discussions in “Ideas for creating an “email profile” thing” and “Using Discourse as a community ticket system”.

Wouldn’t it be better to generate a generic username? Some users might take issue with their e-mail identify being half-way exposed like that (if you see someone’s username is johndoe, more likely than not that person’s e-mail is (or *, * etc.).

(Simon Cossar) #5

Yes, using the email seems like a bad idea. Auto-generating a username from a dictionary of words is quite straightforward.

(Caue Rego) #6

I’d love to hear more about that ticketing system!