Skip to content

Instantly share code, notes, and snippets.

@carmoreira
Created May 22, 2019 16:35
Show Gist options
  • Select an option

  • Save carmoreira/ed67a4030b42871f4a1521039b47aeb9 to your computer and use it in GitHub Desktop.

Select an option

Save carmoreira/ed67a4030b42871f4a1521039b47aeb9 to your computer and use it in GitHub Desktop.
Create user from email submitted
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