Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#52605 closed defect (bug) (fixed)

Reset password email sent in wrong language

Reported by: chouby's profile Chouby Owned by: desrosj's profile desrosj
Milestone: 5.7 Priority: normal
Severity: normal Version: 5.7
Component: Users Keywords: needs-unit-tests has-patch commit dev-reviewed
Focuses: Cc:

Description

Testing the new WP 5.7 feature allowing admin to send a reset password link to users. https://make.wordpress.org/core/2021/02/22/send-reset-password-links-in-wordpress-5-7/ in 5.7-beta3-50398.

On a fresh WordPress site,

  1. Select Spanish as website language.
  2. Assign French as language for the administrator.
  3. Create a subscriber and select German for his/her language.
  4. As admin, click on "Send password reset" (not yet translated) for the German subscriber in the users list.

The email is sent in French (the language of the administrator).
I expect it to be sent in German.

If I assign the default site language to the German user, the email is still sent in French. I expect it to be sent in Spanish.

Attachments (2)

52605.diff (1.1 KB) - added by davidbaumwald 4 years ago.
Quick first pass
52605.2.diff (1004 bytes) - added by Chouby 4 years ago.

Download all attachments as: .zip

Change History (16)

#1 @johnbillion
4 years ago

  • Keywords needs-patch needs-unit-tests added
  • Milestone changed from Awaiting Review to 5.7

Moving to 5.7 to see if we can get a switch_to_locale() in there in time.

@davidbaumwald
4 years ago

Quick first pass

#2 @audrasjb
4 years ago

  • Keywords has-patch added; needs-patch removed

Thanks @davidbaumwald, I tested your patch and it looks good to me.

Testing instructions I followed:

  • Set up your website to English
  • Changes its locale to French
  • Set the website back to English
  • Create a new user
  • Set their locale to French
  • Send a password reset link to the user: the email is in English. It should be in French (user's Locale)
  • Apply the patch proposed by @davidbaumwald
  • Send a password reset link to the user: the email is in French, merveilleux 🍷

#4 @desrosj
4 years ago

  • Owner set to desrosj
  • Status changed from new to reviewing

#5 @desrosj
4 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 50415:

Users: Ensure reset password emails are in the receiving user’s locale.

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.

@Chouby
4 years ago

#6 @Chouby
4 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

May I suggest 52605.2.diff as an improvement?

The reason for my proposal to move the switch_to_locale() above the evaluation of the site name is to allow Polylang to translate the site name on the fly when retrieving the blogname option.

#7 @peterwilsoncc
4 years ago

Thanks @Chouby, this makes sense to me and I am sure will prove useful for other plugins for multilingual sites.

#8 @peterwilsoncc
4 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 50439:

Users: Use localized site title for password reset emails.

When sending password reset emails, switch to the user's locale prior to obtaining the site title to allow for plugins filtering based on locale.

Follow up to [50129,50139-50141,50152,50415].

Props chouby.
Fixes #52605. See #34281.

#9 @peterwilsoncc
4 years ago

  • Keywords dev-feedback fixed-major added
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for [50439] to be back-ported to the 5.7 branch after a second committer reviews.

#10 @SergeyBiryukov
4 years ago

  • Keywords commit dev-reviewed added; dev-feedback fixed-major removed

[50439] looks good to backport.

#11 @SergeyBiryukov
4 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 50440:

Users: Use localized site title for password reset emails.

When sending password reset emails, switch to the user's locale prior to obtaining the site title to allow for plugins filtering based on locale.

Follow up to [50129,50139-50141,50152,50415].

Props chouby.
Merges [50439] to the 5.7 branch.
Fixes #52605. See #34281.

This ticket was mentioned in Slack in #core by monikarao. View the logs.


4 years ago

#13 @apedog
4 years ago

related #49971 - Admin locale setting that is independent of front/site locale and user locale.

#14 @ocean90
3 years ago

In 51077:

Users: Add user’s locale to password reset link to ensure login screen matches the language of the email.

Props walbo.
See #34281, #52605.
Fixes #53321.

Note: See TracTickets for help on using tickets.