Created
June 1, 2017 08:26
-
-
Save aiiddqd/8d5bcb0b7c7bc33ea035b60b71965846 to your computer and use it in GitHub Desktop.
Generate user login in WordPress - function example
This file contains hidden or 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 | |
/** | |
* Generate login for new WP user | |
* | |
* return string uniq login | |
*/ | |
function generate_new_userlogin(){ | |
$users_ids = get_users('fields=ID&number=3&orderby=registered&order=DESC'); | |
$last_id = max($users_ids); | |
$new_id = $last_id+1; | |
$user_login = 'u'. $new_id; | |
return $user_login; | |
} | |
//Use | |
$user = register_new_user( $user_login = generate_new_userlogin(), $user_email = '[email protected]' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment