Privacy: Ensure the privacy data erase fulfillment email is sent in the locale of the user whose data is being erased (or the site's default locale if they are not a registered user) when the administrator fulfilling the request uses a different locale.

Props desrosj, birgire, garrett-eclipse.
Fixes #44721.

git-svn-id: https://develop.svn.wordpress.org/trunk@45039 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2019-03-27 19:41:01 +00:00
parent e2aa3c5efe
commit b957460b7b
6 changed files with 197 additions and 7 deletions

View File

@@ -3140,6 +3140,15 @@ function _wp_privacy_send_erasure_fulfillment_notification( $request_id ) {
return;
}
// Localize message content for user; fallback to site default for visitors.
if ( ! empty( $request->user_id ) ) {
$locale = get_user_locale( $request->user_id );
} else {
$locale = get_locale();
}
$switched_locale = switch_to_locale( $locale );
/**
* Filters the recipient of the data erasure fulfillment notification.
*
@@ -3250,6 +3259,10 @@ All at ###SITENAME###
$email_sent = wp_mail( $user_email, $subject, $content );
if ( $switched_locale ) {
restore_previous_locale();
}
if ( $email_sent ) {
update_post_meta( $request_id, '_wp_user_notified', true );
}