-
Notifications
You must be signed in to change notification settings - Fork 683
Description
What happened?
Description
When I go to a user's page in the control panel and click the 3 dots, then "Send password reset email", the email is always sent in the default site language.
To work around this, I added buttons to the sidebar in the control panel to send the email in different languages. These call a controller function that executes sendPasswordResetEmail.
The issue is that the email still gets sent in the default site language, because the user's preferred language is null.
I tested this with my admin account — when I change my preferred language in the CP (e.g. to English), it works as expected.
I tried setting the preferred language on the user in the controller, but it's read-only.
Is there a way to bypass that, or is there a better/easier way to handle this?
(Not sure if this qualifies as a bug or a feature request — feel free to re-label)
Steps to reproduce
- Extend the user sidebar and add a button that executes a controller function(User::EVENT_DEFINE_SIDEBAR_HTML)
- Go to a user's page in the Control Panel
- click the button that executes the controller function and in the function Craft::$app->getUsers()->sendPasswordResetEmail($user);
Expected behavior
I would like the set preferredLanguage of the user and then send the email in that language.
Actual behavior
Can't set preferredLanguage of user because it is read only. So the email will always be in default language
Craft CMS version
5.7.2
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response