From 89f2e512f57eb69c34b3d355405c7aab54fe1a3d Mon Sep 17 00:00:00 2001 From: desrosj Date: Tue, 23 Feb 2021 16:38:06 +0000 Subject: [PATCH] =?UTF-8?q?Users:=20Ensure=20reset=20password=20emails=20a?= =?UTF-8?q?re=20in=20the=20receiving=20user=E2=80=99s=20locale.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This ensures that reset password emails initiated by an administrator are sent to the user in their preferred locale. Follow up to [50129,50139-50141,50152]. Props chouby, davidbaumwald, audrasjb, johnbillion. Fixes #52605. See #34281. Built from https://develop.svn.wordpress.org/trunk@50415 git-svn-id: http://core.svn.wordpress.org/trunk@50026 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/user.php | 9 +++++++++ wp-includes/version.php | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/wp-includes/user.php b/wp-includes/user.php index 5c6db55afb..0ea54f1a52 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -2759,6 +2759,11 @@ function retrieve_password( $user_login = null ) { $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); } + // Localize password reset message content for user. + $locale = get_user_locale( $user_data ); + + $switched_locale = switch_to_locale( $locale ); + $message = __( 'Someone has requested a password reset for the following account:' ) . "\r\n\r\n"; /* translators: %s: Site name. */ $message .= sprintf( __( 'Site Name: %s' ), $site_name ) . "\r\n\r\n"; @@ -2807,6 +2812,10 @@ function retrieve_password( $user_login = null ) { */ $message = apply_filters( 'retrieve_password_message', $message, $key, $user_login, $user_data ); + if ( $switched_locale ) { + restore_previous_locale(); + } + if ( $message && ! wp_mail( $user_email, wp_specialchars_decode( $title ), $message ) ) { $errors->add( 'retrieve_password_email_failure', diff --git a/wp-includes/version.php b/wp-includes/version.php index 3556e28469..4e24c6fd35 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.7-beta3-50414'; +$wp_version = '5.7-beta3-50415'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.