I try to redirect my users to a custom page after successfully submitting the lost password form. By default, users are redirected to the "my-account" page.
The method responsible for doing this redirect is called process_lost_password() and is located in plugins/woocommerce/includes/class-wc-form-handler.php and looks like follows:
/**
* Handle lost password form.
*/
public static function process_lost_password() {
if ( isset( $_POST['wc_reset_password'] ) && isset( $_POST['user_login'] ) && isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'lost_password' ) ) {
$success = WC_Shortcode_My_Account::retrieve_password();
// If successful, redirect to my account with query arg set.
if ( $success ) {
wp_redirect( add_query_arg( 'reset-link-sent', 'true', wc_get_account_endpoint_url( 'lost-password' ) ) );
exit;
}
}
}
Unfortunately, this method does not offer any action to hook into.
Is there a way to override this method or change the redirect link in any other way?
答案 0 :(得分:0)
Since process_lost_password() is run as an 'wp_load' action
add_action( 'wp_loaded', array( __CLASS__, 'process_lost_password' ), 20 );
You simply need to add your own action with a higher priority
add_action( 'wp_loaded', 'your_handler', 19 );
答案 1 :(得分:0)
我通过下面的方法解决了该问题 WooCommerce 电子邮件**** 因为我是管理员,所以将您的电子邮件一直放置在框中,直到显示“发件人地址”的底部为止,然后删除管理员电子邮件地址。
我做了几个虚拟帐户,现在所有密码都能很好地工作。
我创建了一个页面,为我的永久链接添加了端点到/ lost-password /。检查自定义标题,并在页面中间选中标题框,然后发布页面。这为我解决了这个问题。