How to display user first name as username

I prefer the username to consist of the user’s first name rather than their full name. Upon the user’s initial login, I would like the system to automatically set the username using only the first name.
E.G Full name: Maria Jose → username: Maria

So instead of the username be Maria_Jose, and want it to be Maria

How I can accomplish that?

Are you looking for the prioritize username in ux site setting? This displays the username, which in your example was Maria before displaying Maria Jose.

1 Like

The username can be automatically generated using one of three options:

  1. Based on Email
  2. Based on the user’s full name
  3. Random username

I prefer the name to be generated using the second option (Based on the user’s full name), but specifically, I want to utilize only the user’s first name.

To summarize, the username should automatically be selected and consist only of the user’s first name, not the full name.

I don’t know the answer but I’m wondering what would happend when there is several marias or johns? Username must be unique.

3 Likes

Here are the admin-settings related to names/ usernames:

image

image

image

image

image

3 Likes

I’m familiar with the existing configurations, but unfortunately, they don’t address my specific objective. In our discourse system, we employ a Single Sign-On (SSO) mechanism for login, and users don’t have permission to update their usernames. The registration pop-up is also hidden.

Currently, the username is generated from the ‘name’ field, which includes both the first and last names. My goal is to have the username reflect only the user’s first name.

Is this achievable, and are there any plugins or scripts available to facilitate this customization?

Discourse automatically appends a number to the end of the username. (e.g Maria1, Maria2)

It’s unclear to me. Is the end goal to display the first name regardless of how the username is created, or do you still also want the username to be created with only the first name?

If the former, you can visually make changes with a theme component to see only the first name in place where the username is displayed (assuming name has this format “firstname lastname”). Would that work for you?

eg:
from
image
to
image

Then your SSO system is responsible for assigning usernames. It’s what is generating usernames, not discourse, right?

4 Likes

yes, that would work for me

How I can implement this?

Yes, but then it is not anymore plain first name.

I think is discourse. I’m following the rules created here: FEATURE: Optionally skip using real name when suggesting usernames by davidtaylorhq · Pull Request #16592 · discourse/discourse · GitHub

yes, you’re right, it’s not.
For now, it works for our use case.

I can make you a small component later. :+1:

1 Like