Closed Naatan closed 12 years ago
Thanks Nathan, it is a very fair point that md5 will never be of use to anyone (well, unless they remember to login with their social media account).
I found out recently that WP username can be an email address, so am considering using email as username, as this should be unique by account anyway.
What do you think of that instead?
That does make sense, though personally I wouldn't use it like that since it would be inconsistent with the default wordpress account behaviour.
Anyway, either solution is better than the current md5 solution.
I was just thinking about your idea to use their email as their username and think there would 2 additional issues with this setup.
One, twitter doesn't give you the email address, so you have to fall back on the old method or something like it (such as my solution), which is fine, but again.. it causes inconsistency in usernames. Some people (like me) can be a bit OCD about that :p
Two, the users initial nickname is based on their username, meaning their username would become their email address, which is a privacy concern. You could work around this but you'd be adding a whole lot of extra logic to address a problem that doesn't really need to be there.
You're spot on, I just found issue number 2 occurring on another site I manage with an unrelated plugin.
Your solution is the winner and merging now. Though some folks will still get a username like info4 or contact5! heh
Nice use of recursion too. Do you do any freelance WP work? I always like to keep tabs on OCD WP devs available for freelance. ;-)
Of course the ideal solution would be to show them a prompt which lets them choose / confirm their username, but I think appending a number is an acceptable workaround for a quick solution. The main goal is to give them a username that they can remember and that represents them properly.
I do a bit of consulting on the side, feel free to contact me :)
Added function that generates more readable alternatives when a username is already taken, tries up to 5 times to append a number at the end, after that adds first 3 characters of md5 sum plus number in iteration at the end to ensure the db doesn't get bombed with common name checkups.
I know you added a filter for this, but I feel the default behavior should do a better job of finding alternatives, rather than immediately falling back on an md5 checksum, which will never be a desirable use case for anyone.