0

I'm trying to redirect a user after they have reset their password. I'm using the following code, based on an example from the wordpress docs.

add_filter( 'lostpassword_redirect', 'my_redirect_home' );
function my_redirect_home( $lostpassword_redirect ) {
    return home_url() . '/my-account/';
}

As far as I can tell, the filter is never hit. I've tried replacing the return with an exit; but nothing changes. This seems pretty straight forward. Am I missing something?

Edit: To clarify, I want to redirect them after they have entered their new password and it has been accepted. I want to redirect them to the login form so that they can use the password they've just set up.

1
  • You mean redirecting after you press "Get New Password" on the /wp-login.php?action=lostpassword page ? What's the landing page for the above code? Any other redirects from your /my-account/ page?
    – birgire
    May 12, 2016 at 11:39

1 Answer 1

1

I was missing something. Woocommerce accounts are different from normal Wordpress accounts. The code that I was looking for was:

function woocommerce_new_pass_redirect( $user ) {
  wp_redirect( get_permalink(woocommerce_get_page_id('myaccount')));
  exit;
}

add_action( 'woocommerce_customer_reset_password', 'woocommerce_new_pass_redirect' );

I found it on stackoverflow.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.