Created
August 16, 2018 12:30
-
-
Save alordiel/41c2c12db43f4311c40663370992b732 to your computer and use it in GitHub Desktop.
WordPress - create unique username by provided email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function create_unique_user_name_by_email ($email) { | |
$email_name = explode( '@', $email ); | |
if ( ! get_user_by( 'login', $email_name[0] ) ) { | |
$username = $email_name[0]; | |
} else { | |
$username = uniqid( $email_name[0], false ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment