Created
February 15, 2016 10:39
-
-
Save jawdatls/e7e972b141fd9343d920 to your computer and use it in GitHub Desktop.
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
if( null == username_exists( $email_address ) ) { | |
// Generate the password and create the user | |
$password = wp_generate_password( 12, false ); | |
$user_id = wp_create_user( $email_address, $password, $email_address ); | |
// Set the nickname | |
wp_update_user( | |
array( | |
'ID' => $user_id, | |
'nickname' => $email_address | |
) | |
); | |
// Set the role | |
$user = new WP_User( $user_id ); | |
$user->set_role( 'contributor' ); | |
// Email the user | |
wp_mail( $email_address, 'Welcome!', 'Your Password: ' . $password ); | |
} // end if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment