Well I was overthinking this way too much!!
All you need to do for the form is put in a dummy value for user_login so that it looks like:
<input class="form-control" type="hidden" name="user_login" id="user_login" value="ABC">
On the top of the page I remove the $current_username = $current_email;
.
On the form submission code, I make the form use $_POST['user_email']
as the user_login value.
if (isset($_POST['user_email']))
{
$user_email = $_POST['user_email'];
$user_login = $_POST['user_email'];
// Check captch if enabled
if (class_exists("ReallySimpleCaptcha"))
{
$captcha_instance = new ReallySimpleCaptcha();
if ( !isset($_POST['cuar_captcha_prefix']) || !isset($_POST['captcha']))
{
$this->form_errors[] = new WP_Error('captcha',
__("You must write the code displayed in the image above.", 'cuarlf'));
return;
}
else
{
$prefix = $_POST['cuar_captcha_prefix'];
$code = $_POST['captcha'];
$captcha_checked = $captcha_instance->check($prefix, $code);
$captcha_instance->remove($prefix);
$captcha_instance->cleanup();
if ( !$captcha_checked)
{
$this->form_errors[] = new WP_Error('captcha', __("The code you entered is not correct.", 'cuarlf'));
return;
}
}
}
$errors = CUAR_WPLoginHelper::register_new_user($user_login, $user_email);
if (is_wp_error($errors))
{
$this->form_errors[] = $errors;
return;
}
}
else
{
$this->form_errors[] = new WP_Error('user_login', __("You must enter a valid username and a valid email address.", 'cuarlf'));
return;
}
$lf_addon = $this->plugin->get_addon('login-forms');
$this->form_messages[] = sprintf(__('An email has been sent with the instructions to activate your account. '
. 'You can then go to the <a href="https://wordpress.stackexchange.com/questions/270751/%1$s" class="alert-link">login page</a>', 'cuarlf'), $lf_addon->get_login_url());
$this->should_print_form = false;
}