Reputation: 57
The Link to the forget password in woocommerce error message is not redirecting to my custom page but going to wordress default forget password page. I need to change that to redirect to my custom page like "site_url/my-account/lost-password". is there any hook to change the redirection of lost password in woocomerce?
Upvotes: 0
Views: 4576
Reputation: 3504
Option 1
Check my screenshot from there you can change it.
https://www.screencast.com/t/bNKTJTu4A
I have uploaded screenshot here as well
Option 2 :
add_filter( 'lostpassword_url', 'wdm_lostpassword_url', 10, 0 );
function wdm_lostpassword_url() {
return site_url('/customslug');
}
Option 3
This for the specific error message
add_filter('login_errors', 'login_error_message', 99, 2);
function login_error_message($error) {
//check if that's the error you are looking for
$pos = strpos($error, 'ERROR');
$pos2 = strpos($error, 'The password field is empty.');
if (is_int($pos) && $pos2 == '') {
//its the right error so you can overwrite it
$error = "ERROR: Invalid username or password. <a href=" . get_the_permalink(2) . "> Lost your password?</a>"; // instead of 2 you can put your page id or slug
}
return $error;
}
Upvotes: 1