User defined password at registration – registration email sends auto generated pass

Updating some meta fields on registration and providing the user the option to pick a password yet the registration email sends the auto generated password. User defined password works and not emailed pass.

add_action( 'user_register', 'jwh_register_extra_fields', 100 );
function jwh_register_extra_fields( $user_id, $password = '', $meta = array() )  {
$userdata = array();

$userdata['ID'] = $user_id;
if ( $_POST['password'] !== '' ) {
    $userdata['user_pass'] = $_POST['password'];
}

$userdata['first_name'] = $_POST['first_name'];
$userdata['last_name'] = $_POST['last_name'];
$userdata['user_url'] = $_POST['user_url'];

$new_user_id = wp_update_user( $userdata );
}

Related posts

1 comment

  1. Welcome to WPSE. You can use wp_insert_user, you don’t need to hook onto anything.

    Assuming here they fill out a form with a name, username, email and password field, and you capture it however you want.

    $name_array = explode(' ',$_POST['name']);
    $user = array(
        'user_login' => $_POST['username'],
        'user_pass' => $_POST['password'],
        'user_email' => $_POST['email'],
        'first_name' => $name_array[0],
        'last_name' => $name_array[1],
                );
    $user_id = wp_insert_user( $user );
    
    wp_new_user_notification( $user_id, $_POST['password'] );
    

Comments are closed.