You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WooCommerce:提交找回密码表单后自定义页面重定向问题

Custom Redirect After WooCommerce Lost Password Form Submission

Hey there! Let's fix that password reset redirect without messing with WooCommerce core files (because we all know updates will overwrite those changes faster than you can say "oops").

The Default Behavior

Right now, after a user submits the lost password form successfully, WooCommerce sends them straight to the my-account page via the process_lost_password() method in plugins/woocommerce/includes/class-wc-form-handler.php. But you want them landing on a custom page instead.

The Best Solution: Use a Filter Hook

WooCommerce gives us a handy filter to override this redirect—no core edits needed. Just add this code to your child theme's functions.php file, or a custom plugin (child themes are safer than parent themes, by the way):

/**
 * Override default lost password redirect URL
 */
add_filter( 'woocommerce_lost_password_redirect', 'my_custom_lost_password_redirect' );
function my_custom_lost_password_redirect() {
    // Swap out this URL with your custom page's address
    return home_url( '/password-reset-success/' );
}

What This Does

  • The woocommerce_lost_password_redirect filter hooks into the password reset flow right before WooCommerce sends the user off to the default page.
  • Our custom function tells WooCommerce to use your specified URL instead of my-account.

If you absolutely have to edit the core file (seriously, only do this if you're okay with redoing it every time WooCommerce updates), here's how:

  1. Open plugins/woocommerce/includes/class-wc-form-handler.php
  2. Find the process_lost_password() method
  3. Look for the line that says:
    wp_redirect( wc_get_page_permalink( 'myaccount' ) );
    
  4. Replace it with your custom URL, like:
    wp_redirect( home_url( '/your-custom-thank-you-page/' ) );
    

But again—don't do this unless you have no other option. Hooks are the way to go for maintainable code.

内容的提问来源于stack exchange,提问作者turboLoop

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 04:10:33