Skip to content

[5.x]: No way to control language of password reset email from the cp if user has no preferred language #17333

@jeffOption5

Description

@jeffOption5

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

  1. Extend the user sidebar and add a button that executes a controller function(User::EVENT_DEFINE_SIDEBAR_HTML)
  2. Go to a user's page in the Control Panel
  3. 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

Installed plugins and versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions