Best Jquery ,javascript, HTML5 CSS3 tutorial with jquery examples, php script , demos for beginners, web designers and web developers.


Jquery Training

Jquery training blog

Auto login after password reset in WordPress

I am going to explain how to do auto login in WordPress after password reset.

If you are a WordPress developer, have you ever faced a situation when you need to do auto login after password reset in WordPress? i faced the situation. Do you know how to do auto login after password reset in WordPress?

Actually before a week i faced the issue, searched over net, but not found satisfactory result. At last i gone through the documentation and found some useful hooks.

In WordPress there are before and after hooks available, like post save hook.

In my case i found some useful hooks

1) password_reset action hook


add_action( 'password_reset', 'before_password_update', 10, 2 );

function before_password_update( $user, $new_pass ) {
//write code before password reset.

This hook runs after the user submits a new password and before the new password is set. Mean you have entered the new password but password not updated in db.
2) after_password_reset hook


function action_after_password_update( $wp_password_change_notification ) {
//write code after password reset.

add_action( 'after_password_reset', 'action_after_password_update', 10, 1 );


This hook runs after the user submits a new password and after the new password is set.

3) If you are using the WooCommerce in this case you have to use the following hook



function action_woocommerce_reset_password( $user ) {
$creds = array(
'user_login' => $login,
'user_password' => $pass,
'remember' => true

wp_signon( $creds, false );
add_action( 'woocommerce_customer_reset_password', 'action_woocommerce_reset_password', 10, 1 );


WooCommerce overrides the core WordPress login so, if you are using WooCommerce you have use the exact above code for auto login after password reset. In action_woocommerce_reset_password function wp_signon core function isused for login. if we pass the required parameter as written in the code, wp_signon function will do login in wordpress.
The above piece of code will do all the thing as soon as you entered the new password.

About the author

Joydeb Choudhury holds a Master's degree in Computer Application from I.G.N.O.U. After working as a web developer in various companies he has started bloging in 2016.

Recent Posts of blog

Downalod Free Php Scripts