Created
May 22, 2019 16:35
-
-
Save carmoreira/ed67a4030b42871f4a1521039b47aeb9 to your computer and use it in GitHub Desktop.
Create user from email submitted
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
| add_action('adqv_email_submitted', 'advq_create_new_user_from_email'); | |
| function advq_create_new_user_from_email( $email_address ){ | |
| 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 | |
| ) | |
| ); | |
| } // end if | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment