From cafdd0b6accfcc43ffa49db3af4cdfd9f63d96f9 Mon Sep 17 00:00:00 2001 From: Linty Date: Wed, 4 Dec 2024 15:11:32 +0100 Subject: [PATCH] (cp bb8f3d571) fixes #2287 switch language before sending the email --- include/ws_functions/pwg.users.php | 3 +++ password.php | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/ws_functions/pwg.users.php b/include/ws_functions/pwg.users.php index 7e65219db..c5cefd8d7 100644 --- a/include/ws_functions/pwg.users.php +++ b/include/ws_functions/pwg.users.php @@ -1023,7 +1023,9 @@ function ws_users_generate_password_link($params, &$service) $first_login = has_already_logged_in($params['user_id']); $generate_link = generate_password_link($params['user_id'], $first_login); $send_by_mail_response = null; + $lang_to_use = $first_login ? get_default_language() : $user_lost['language']; + switch_lang_to($lang_to_use); if ($params['send_by_mail'] and !empty($user_lost['email'])) { if ($first_login) @@ -1044,6 +1046,7 @@ function ws_users_generate_password_link($params, &$service) $send_by_mail_response = false; } } + switch_lang_back(); return array( 'generated_link' => $generate_link['password_link'], diff --git a/password.php b/password.php index 7ae7a00f7..8f3fc4eef 100644 --- a/password.php +++ b/password.php @@ -80,9 +80,12 @@ function process_password_request() // $userdata['activation_key'] = $generate_link['activation_key']; + switch_lang_to($userdata['language']); $email_params = pwg_generate_reset_password_mail($userdata['username'], $generate_link['password_link'], $conf['gallery_title'], $generate_link['time_validation']); + $send_email = pwg_mail($userdata['email'], $email_params); + switch_lang_back(); - if (pwg_mail($userdata['email'], $email_params)) + if ($send_email) { $page['infos'][] = l10n('Check your email for the confirmation link'); return true;