Skip to content

Instantly share code, notes, and snippets.

@aiiddqd
Created June 1, 2017 08:26
Show Gist options
  • Save aiiddqd/8d5bcb0b7c7bc33ea035b60b71965846 to your computer and use it in GitHub Desktop.
Save aiiddqd/8d5bcb0b7c7bc33ea035b60b71965846 to your computer and use it in GitHub Desktop.
Generate user login in WordPress - function example
<?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 = 'name@site.example' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment