Woocommerce丢失了密码重定向到wordpress忘记密码但不是我的自定忘记密码页面

时间:2018-06-04 06:03:17

标签: php wordpress woocommerce

在woocommerce错误消息中忘记密码的链接不是重定向到我的自定义页面,而是转到wordress默认忘记密码页面。我需要更改它以重定向到我的自定义页面,如“site_url / my-account / lost-password”。enter image description here是否有任何钩子可以更改woocomerce中丢失密码的重定向?

1 个答案:

答案 0 :(得分:1)

选项1

从那里检查我的截图,你可以改变它。

https://www.screencast.com/t/bNKTJTu4A

我也在这里上传了截图

enter image description here

选项2:

add_filter( 'lostpassword_url',  'wdm_lostpassword_url', 10, 0 );
 function wdm_lostpassword_url() {
  return site_url('/customslug');
 }

选项3

这是针对特定错误消息的

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;
}
相关问题