In the function that you’re hooking into user_register
, you need to create the user and save the values. First, I’d recommend using wp_insert_user()
instead of wp_create_user()
.
You might do something like this:
$userdata = array(
'user_email' => $email_address,
'user_login' => $user_name,
// this is automatically salted
'user_pass' => 'plain_text_password',
);
// this function returns the user id
$user_id = wp_insert_user( $userdata ) ;
$data = array(
'field_key_name' => $data_one,
'field_key_name_two' => $data_two,
);
foreach( $data as $k => $v ) {
update_user_meta( $user_id, $k, $v );
}
// if wp_insert_user fails, it returns an error object
if ( is_wp_error( $user_id ) ) {
// error
} else {
// success
}
If you are saving the data to a custom table, you would perform that update query in place of update_user_meta()
, which saves your data to the wp_usermeta
table.