If you create the user by passing the values entered to a function that combines them, then you can call it from another that calls wp_insert_user
. Then you can save the username/pass as needed, and use the same function and form when preparing them for WP to check on log-in.
All of the code below is intended for demonstration only. Can’t stress that enough. Definitely look into nonce and validating registration.
Again, this is ONLY a demo of the idea to point in the general direction.
<form>
<input type="text" name"value1" />
<input type="text" name"value2" />
<input type="text" name"value3" />
</form>
Then we have a function to handle the combining of the entries:
<?php
function getting_posted_values() {
if(isset($_POST['value1']) && (isset($_POST['value2']) && (isset($_POST['value3']) {
$value1 = $_POST['value1'];
$value2 = $_POST['value2'];
$value3 = $_POST['value3'];
$new_value = $value1 . $value2 . $value3;
}
return $new_value;
}
Then a hooked function – (for instance if you used Contact Form 7 to manage the form, you could hook wpcf7_before_send_mail
and get access to the post object.) – could call the function below and build the new user:
function build_a_new_user($posted_form) {
$new_value = getting_posted_values($posted_form);
$userdata = array(
'user_login' => $new_value,
'user_pass' => $new_value, //normally: wp_generate_password( 12, false );
'user_email' => //note: not sure but may be required?
'nickname' => $new_value,
'display_name' => $new_value,
'first_name' => $new_value,
'last_name' => $new_value,
'role' => 'subscriber'
);
wp_insert_user($userdata);
}
wp_insert_user() is documented here.
More on handling custom registration here.
For Logging In
Your form with values 1,2,3 would run getting_post_values again by being called within another function that is hooked to log in somehow. Perhaps the login_form_defaults
filter that can edit the args array for the form. The follow is complete speculation as a non-working example.
But the idea is that if you can pass those values to WP’s normal process (perhaps via the authenticate
filter mentioned in your linked example?) as the user/pass, you can forgo doing the checking yourself.
function log_in_handler($posted_form) {
$pass_and_username = getting_posted_values($posted_form);
$args_array = array(
'username_id' => $pass_and_username,
'password' => $pass_and_username);
}
It’s definitely an interesting endeavor. Hope that helps.