woocommerce offtopic - How to change lost password email text using custom plugin wordpress?

admin2025-01-08  5

In wordpress, i want to add one extra parameter(ABC) in lost password link with key (lost password email text).

I have added many hooks.

  1. add_action( 'password_reset', 'password_reset_hook', 10, 2 );
    this hook is not working
  2. add_action( 'wp_loaded', array($this, 'process_user_lost_password' ), 20 );
    when i call above action then lost password key gets generated and updated to database. Then again, default lost password action is getting called and also generating new key and updates to database again. So when i process with old key it shows message "invalid Key". How can i solved this issue. How can i stop default reset password mail firing programmatically. What is the hook to change lost password email text for wordpress?
  3. add_filter( 'retrieve_password_message', 'my_retrieve_password_message', 10, 4 );
    This filter is not working.

Please help me.

In wordpress, i want to add one extra parameter(ABC) in lost password link with key (lost password email text).

I have added many hooks.

  1. add_action( 'password_reset', 'password_reset_hook', 10, 2 );
    this hook is not working
  2. add_action( 'wp_loaded', array($this, 'process_user_lost_password' ), 20 );
    when i call above action then lost password key gets generated and updated to database. Then again, default lost password action is getting called and also generating new key and updates to database again. So when i process with old key it shows message "invalid Key". How can i solved this issue. How can i stop default reset password mail firing programmatically. What is the hook to change lost password email text for wordpress?
  3. add_filter( 'retrieve_password_message', 'my_retrieve_password_message', 10, 4 );
    This filter is not working.

Please help me.

Share Improve this question asked Jan 22, 2020 at 5:48 Jitendra TripathiJitendra Tripathi 1
Add a comment  | 

1 Answer 1

Reset to default 0

The filter for the Message that is sent to reset your password is retrieve_password_message. You use it like this:

add_filter('retrieve_password_message','my_awesome_new_password_reset_email',10,4);

function my_awesome_new_password_reset_email($message, $key, $user_login, $user_data){
   $message = "Hey, you need a new Password? Click here: ".site_url( "wp-login.php?action=rp&key=$key&login=".rawurlencode( $user_login ),'login')."!";
   return $message;
}

$message is the original E-Mail Body, $key is the reset password key, $user_login is the username and $user_data is the WP_User object of the User. If you return an empty string for $message, no E-Mail will be sent for the "lost password" action.

Happy Coding!

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736267012a1168.html

最新回复(0)