WordPress.org

Make WordPress Core

Ticket #32430: 32430.diff

File 32430.diff, 5.1 KB (added by MikeHansenMe, 3 years ago)

send similar email to original email if email is changed

  • src/wp-includes/pluggable.php

     
    16561656/**
    16571657 * Notify the blog admin of a user changing password, normally via email.
    16581658 *
     1659 * Notify the user of any change to their password, also via email.
     1660 *
    16591661 * @since 2.7.0
    16601662 *
    16611663 * @param object $user User Object
    16621664 */
    16631665function wp_password_change_notification(&$user) {
    1664         // send a copy of password change notification to the admin
     1666        // send password change notification to the admin
    16651667        // but check to see if it's the admin whose password we're changing, and skip this
    16661668        if ( 0 !== strcasecmp( $user->user_email, get_option( 'admin_email' ) ) ) {
    16671669                $message = sprintf(__('Password Lost and Changed for user: %s'), $user->user_login) . "\r\n";
     
    16691671                // we want to reverse this for the plain text arena of emails.
    16701672                $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    16711673                wp_mail(get_option('admin_email'), sprintf(__('[%s] Password Lost/Changed'), $blogname), $message);
     1674
     1675        //send password change notification to the user
     1676        } else {
     1677                /* translators: Do not translate USERNAME, ADMIN_EMAIL, EMAIL, SITENAME, SITEURL: those are placeholders. */
     1678                $email_text = __( 'Howdy ###USERNAME###,
     1679
     1680This notice is confirming you recently changed your password on ###SITENAME###.
     1681
     1682If you did not change your password, please contact the Site Administrator at
     1683###ADMIN_EMAIL###
     1684
     1685This email has been sent to ###EMAIL###
     1686
     1687Regards,
     1688All at ###SITENAME###
     1689###SITEURL###' );
     1690
     1691                /**
     1692                 * Filter the email text sent when the user's password is changed.
     1693                 *
     1694                 * The following strings have a special meaning and will get replaced dynamically:
     1695                 * ###USERNAME###    The current user's username.
     1696                 * ###ADMIN_EMAIL### The link to click on to confirm the email change.
     1697                 * ###EMAIL###       The new email.
     1698                 * ###SITENAME###    The name of the site.
     1699                 * ###SITEURL###     The URL to the site.
     1700                 *
     1701                 * @since 4.3
     1702                 *
     1703                 * @param string $email_text      Text in the email.
     1704                 */
     1705                $content = apply_filters( 'user_password_change_email_content', $email_text );
     1706
     1707                $content = str_replace( '###USERNAME###', $user->user_login, $content );
     1708                $content = str_replace( '###ADMIN_EMAIL###', get_option( 'admin_email' ), $content );
     1709                $content = str_replace( '###EMAIL###', $user->user_email, $content );
     1710                $content = str_replace( '###SITENAME###', get_option( 'blogname' ), $content );
     1711                $content = str_replace( '###SITEURL###', get_option( 'siteurl' ), $content );
     1712
     1713                wp_mail( $user->user_email, sprintf( __( '[%s] Notice of Password Change' ), wp_specialchars_decode( get_option( 'blogname' ) ) ), $content );
    16721714        }
    16731715}
    16741716endif;
  • src/wp-includes/user.php

     
    21212121        // If password is changing, hash it now.
    21222122        if ( ! empty($userdata['user_pass']) ) {
    21232123                $plaintext_pass = $userdata['user_pass'];
    2124                 $userdata['user_pass'] = wp_hash_password($userdata['user_pass']);
     2124                $userdata['user_pass'] = wp_hash_password( $userdata['user_pass'] );
    21252125        }
    21262126
    2127         wp_cache_delete($user[ 'user_email' ], 'useremail');
     2127        wp_cache_delete( $user[ 'user_email' ], 'useremail' );
    21282128
     2129        if ( $user['user_email'] !== $userdata['user_email'] ) {
     2130                $email_text = __( 'Howdy ###USERNAME###,
     2131
     2132This notice is confirming you recently changed your email on ###SITENAME###.
     2133
     2134If you did not change your email, please contact the Site Administrator at
     2135###ADMIN_EMAIL###
     2136
     2137This email has been sent to ###EMAIL###
     2138
     2139Regards,
     2140All at ###SITENAME###
     2141###SITEURL###' );
     2142
     2143                /**
     2144                 * Filter the email text sent when the user's email is changed.
     2145                 *
     2146                 * The following strings have a special meaning and will get replaced dynamically:
     2147                 * ###USERNAME###    The current user's username.
     2148                 * ###ADMIN_EMAIL### The link to click on to confirm the email change.
     2149                 * ###EMAIL###       The new email.
     2150                 * ###SITENAME###    The name of the site.
     2151                 * ###SITEURL###     The URL to the site.
     2152                 *
     2153                 * @since 4.3
     2154                 *
     2155                 * @param string $email_text      Text in the email.
     2156                 */
     2157                $content = apply_filters( 'user_email_change_email_content', $email_text );
     2158
     2159                $content = str_replace( '###USERNAME###', $user->user_login, $content );
     2160                $content = str_replace( '###ADMIN_EMAIL###', get_option( 'admin_email' ), $content );
     2161                $content = str_replace( '###EMAIL###', $user->user_email, $content );
     2162                $content = str_replace( '###SITENAME###', get_option( 'blogname' ), $content );
     2163                $content = str_replace( '###SITEURL###', get_option( 'siteurl' ), $content );
     2164
     2165                wp_mail( $user['user_email'], sprintf( __( '[%s] Notice of Email Change' ), wp_specialchars_decode( get_option( 'blogname' ) ) ), $content );
     2166        }
     2167
    21292168        // Merge old and new fields with new fields overwriting old ones.
    2130         $userdata = array_merge($user, $userdata);
     2169        $userdata = array_merge( $user, $userdata );
    21312170        $user_id = wp_insert_user($userdata);
    21322171
    21332172        // Update the cookies if the password changed.