Restrict username to user first name

When users sign up on the forum using OpenID, their email and username get automatically filled and validated. If the chosen username is taken, Discourse adds a number to make it unique. The username is chosen based on the user name.

The issue is that we want the username to be only the user’s first name, not the full name. I’ve been trying to change the username during registration, but I haven’t found a successful way yet. Any suggestions on how to fix this would be appreciated.

Screenshot from 2024-03-02 13-17-21

you posted this already I think

2 Likes

Now it is more clear what I want to achieve, and the problems I’m facing

1 Like

If you control the openID server then you should be able to have it send whatever you want to Discourse.

This might help:

Looks like you can populate preferred_nickname with the username you think you want. What are you sending in that field? If it’s empty or their full name, that would be a good first thing to change.

1 Like

You can also try this component; this should do what you want in your context.

It hides the username field and generates its value based on the name field, extracting only the first name.

It expects the following settings enabled:

  • full_name_required
  • prioritize_username_in_ux
3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.