Admin setting to display nickname or first name, default to username
Closed this issue · 6 comments
I see that the extension uses the wordpress Username, which is the user_login
field to display in flarum.
Unfortunately, in wordpress, users can't change their username. They can however change First Name, Last Name and Nickname. They can then choose what to Display their name as.
It would be great to have an admin option in the extension so flarum can be set to use either Nickname or what the Display name setting is.
That would be great! 👍
Last I checked Flarum core only has a username, and doesn't seem to have any kind of display name.
Looks like Beta 15 added a nicknames extension, might be possible to do something similar to what it does. Would have to look into it.
If inconsistent names is your concern, you can use my plugin to prevent WP users from changing their display name.
I imagine there's also some WordPress plugins that can allow you to change your username (I've changed WP usernames via MySQL, and nothing bad happened).
I have an ecommerce site and my concern is that users do not want their real names to show up in flarum. After registration as customer, the wordpress username is firstname.lastname
Thank you for pointing to the flarum/nicknames extension, I've just installed it and I'll have to look into that. I need to make sure that the wordpress username is not exposed by url, but in this case there should be a wordpress plugin that changes the wordpress username initial creation to some random value... 👍
I've looked into the options we have and I've found two three possible ways of doing that.
First, what's the requirement:
- Displayname/Nickname in Wordpress and Flarum should always be the same
- They user should be able to change his displayed name
Solution A (Alter the Wordpress Username --> Flarum Username)
Since this extension already uses the Wordpress Username as Displayname, no change is needed to this extension. However, we need to find/create a wordpress Plugin or Snippet that syncronizes the Display name with the User name.
There is a plugin available that lets the user change it's username, but if you have a woocommerce site, the wordpress profile page is not visible to the user, only the account page where the Display name can be changed. So some work needs to be done to sync the display name with the user name within wordpress or to just replace the display name field by a user name field in woocommerce (with all the consequences of validating user input and so on)
I'm not sure if there are any negative side effects (besides the customer needs to login again after changing its username), at least flarum seems to have no problems with that.
Solution B (Displayname --> Flarum Nickname Extension)
This may be the cleaner way to do it because it lets the username out of all and uses the displayname for what it's supposed to be, the displayed name. For it to happen, this extension needs to:
- Check wether the flarum/nicknames extension is installed
- If so, change the users nickname to the value of Display Name in wordpress
- Update when the Display Name in wordpress changes
- Provide an option to redirect to the profile page when the Flarum "Change Nickname" button is clicked (same behavior as with "Change password" and "Change mail")
Solution C (Let the admin choose --> Flarum Username)
Closest to that what @moinzaman did propose originally. Choose what source (user_login, user_nicename, display_name, firstname, ...) to use for flarum username. Restriction: Not every display_name or firstname would work and not unique.
Solution D (Let the admin choose --> Flarum Displayname-Driver)
Choose what source (user_login, user_nicename, display_name, firstname, ...) to use and implement custom display driver to show it. Would remove the flarum username restrictions from the display name.
I would prefer solution B D, because it seems to me the cleanest solution. So, this is my feature request - I partly tried to implement it (#7), but without the display driver and without access to first name/last name (in fact I implemented C).
New in version 1.4.0, this extension now registers a display name driver which can display WordPress display names.
I've managed to update flarum to v1.0 and your extension to 1.5.0. I've tested it and it works great! I can now change the display name driver to "Wordpress", and it will use the same name as flarum displayname as the user can freely choose at the woocommerce user profile page.
Also, when I change the slug-driver from "default" to "id", the users URL won't expose the users real name anymore, instead showing a number.
Perfect! Thank you very much for your work.