ClassicPress PetitionsClassicPress Petitions
This is a read-only archive. Post or comment on the live version of this page on our forums.

change user slug - do not expose user name

September 8, 2018 · 00:48 · Ina

could be a cryptic random string

+8 more

Can you elaborate on the purpose of this - I'm thinking you're thinking of security? If so, it would probably take less code to force users to login via email address rather than username, while still leaving the usernames reader-friendly on the frontend.


Indeed, the purpose is security. I actually mean to change the user's nickname (= user slug, which happens to be the user's username by default) automatically to something else.
I am not happy with all author pages exposing the author's username (= nickname = login name) in the frontend (or to bots).
Of course, the nickname is editable in the backend, but not for users who just sign up and/or have no access to the backend. Think about websites with lots of registered authors or membership sites.
Not everyone knows about changing their nickname in order to hide their username a.k.a. login name in the frontend. I myself did not know for quite a while what this nickname actually is used for.

Regarding the automation of setting the nickname: One could use the display_name instead of a cryptic string but that would require to have at least the first_name available. Which is not the case as long as it is not a required field and also included in the registration form. And you would have to check it against the username.
So I think it is best to make the nickname a unique cryptic string of some sort when a new user is registered. This is the easiest solution I came up with so far and have it included in all WP sites I build.

Your idea with using only the email address for signup is, of course, a quicker workaround but here an additional question must be asked:
How many people would acutally prefer this?
If it's on me, for the login I would rather use a username that nobody knows instead of an email address that people might already know.


Thanks for elaborating. I do believe using an email address to login is better practice than a username, but I don't have any "proof" so we'll just call it opinion. ;) However, I'd never leave security decisions up to "what will people prefer". What people prefer is never the most secure. Of course, there's the UX aspect, as well; showing usernames is much better than obfuscating them, again, in my opinion. :)


Actually, I would prefer it if the unique identifier was NOT the email address: I think there are many legitimate reasons to have more than one account for any user, like having on admin account and one as editor. Of course, for public accounts there should be some restriction. But admins (or others entitled to do so) should be able to create multiple accounts using the same email address.
So, for me, some kind of random initial "nick" would be okay, if it includes an explanation to the user why this is used and why they should not use their real names.
May be, the username should be (optionally) generated as random strings. With password safes like KeePass there should be no problem.