I'm building a custom page for password recovery...
I get the action "login_form_lostpassword" to redirect the custom page.
function new_lost_password_form()
{
if ( 'GET' == $_SERVER['REQUEST_METHOD'] ) {
if (is_user_logged_in()) {
$this->redirect_logged_in_user();
exit;
}
wc_get_template('page-templates/lost-password-form.php');
exit;
}
}
add_action('login_form_lostpassword', 'new_lost_password_form');
When i try recover a password everything works fine, But when an error occurs as the input blank the wordpress redirect to the default recovery page.
This happen why the wordpress reads the wp-login.php first...
As i will make to wordpress override the content of recovery page wich is in wp-login.php ?
The block must override is:
case 'lostpassword' :
case 'retrievepassword' :
if ( $http_post ) {
$errors = retrieve_password();
if ( !is_wp_error($errors) ) {
$redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : 'wp-login.php?checkemail=confirm';
wp_safe_redirect( $redirect_to );
exit();
}
}
if ( isset( $_GET['error'] ) ) {
if ( 'invalidkey' == $_GET['error'] ) {
$errors->add( 'invalidkey', __( 'Your password reset link appears to be invalid. Please request a new link below.' ) );
} elseif ( 'expiredkey' == $_GET['error'] ) {
$errors->add( 'expiredkey', __( 'Your password reset link has expired. Please request a new link below.' ) );
}
}
in the file wp-login.php