skip to Main Content

I am a beginner in wordpress.I’m doing an ecommerce website and the problem is when the user reset their password after changing it a mail has been sent to the user (like your password has been changed).How can i change the email text content when the password is successfully changed and then an email is being sent to the user?

After changing the password the user is getting the following mail-

Hello abc

To inform you that your password has been changed.

If it was not you, please contact the following site administrator.
[email protected]

This e-mail has been sent to [email protected]

2

Answers


  1. You can use this function to modify emails content in your theme functions file (functions.php):

    /* Start Of Function for changing the Forgot password mail content */

    add_filter('retrieve_password_message', 'forgot_mail_contnet', 10, 2);
    
    function forgot_mail_contnet($message, $key) {
    
        $user_data = '';
        // If no value is posted, return false
        if (!isset($_POST['user_login'])) {
            return '';
        }
        // Fetch user information from user_login
        if (strpos($_POST['user_login'], '@')) {
    
            $user_data = get_user_by('email', trim($_POST['user_login']));
        } else {
            $login = trim($_POST['user_login']);
            $user_data = get_user_by('login', $login);
        }
        if (!$user_data) {
            return '';
        }
        $user_login = $user_data->user_login;
        $user_email = $user_data->user_email;
    
        $site_url = get_site_url();
    
        $reset_url = network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login');
    
        // here $message it the mail content , which you can modify as per your requirment and $key is activation key
        // after modifying you must return $message
        return $message . "- <a href=' " . $reset_url . " '> click Here </a>";
    }
    
    /* End Of Function for changing the Forgot password mail content */
    
    Login or Signup to reply.
  2. Just edit below file from root directory located in
    /wp-includes/user.php line no. 2009 or search for ‘Hi ###USERNAME###, and you will find the message body as below that you can customize it as you would like.

    $pass_change_text = __(
    'Hi ###USERNAME###,
    
    This notice confirms that your password was changed on ###SITENAME###.
    
    If you did not change your password, please contact the Site Administrator at ###ADMIN_EMAIL###
    
    This email has been sent to ###EMAIL###
    
    Regards,
    All at ###SITENAME###
    ###SITEURL###'
                );
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search