Ask your WordPress questions! Pay money and get answers fast! (more info)

password_reset action function does not work on multisite? WordPress

  • SOLVED

I am trying to use this function on my multisite.

But the redirect works, but the password does not reset. :/



I diactivated my theme, and activated the twentytwelve theme and insert the function below...




function wpse_lost_password_redirect() {
wp_redirect( home_url().'?test' );
exit;
}
add_action('password_reset', 'wpse_lost_password_redirect');



I tested it over and over - and even thought the redirect works, my password is still the old one. As soon as I remove this function, the password resets fine.



Can anyone help me please.

Thanks

Answers (2)

2013-02-15

Francisco Javier Carazo Gil answers:

Josh,

Have you tried to force a password reset directly in code?


add_action( 'password_reset', 'my_password_reset' );

function my_password_reset( $user, $new_pass ) {
wp_set_password( $new_pass, $user->ID );
wp_redirect( home_url().'?test' );
exit;
}


Francisco Javier Carazo Gil comments:

Maybe there is a bug in WP-Core respect to this, but with this function you will force the password update.


Josh Cranwell comments:

thank you for your help

2013-02-15

Kailey Lampert answers:

The 'password_reset' hook fires before the function to set the new password, so with the header statement, that never happens and the new password doesn't get saved.

What Francisco suggests will work, but you'll need to make sure you adjust the action just a bit:

add_action( 'password_reset', 'my_password_reset', 10, 2 );
function my_password_reset( $user, $new_pass ) {
wp_set_password( $new_pass, $user->ID );
wp_redirect( home_url().'?test' );
exit;
}


Josh Cranwell comments:

I used your function thank you