Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
I will look into this and maybe I can set a language so we can translate it through the mail_edit module. But the real translation of the email can only be done by mail_edit module as these are core mails and not translatable through core methods.
/**
* Implementation of hook_form_user_pass_alter().
*/
function foo_form_user_pass_alter(&$form, $form_state) {
// remove the default submit callback
array_shift($form['#submit']);
$form['#submit'][] = 'foo_user_pass_submit';
}
function foo_user_pass_submit($form, &$form_state) {
$account = $form_state['values']['account'];
// Mail one time login URL and instructions using current language.
drupal_set_message(print_r($account->language, TRUE));
_user_mail_notify('password_reset', $account, $account->language);
watchdog('user', 'Password reset instructions mailed to %name at %email.', array('%name' => $account->name, '%email' => $account->mail));
drupal_set_message(t('Further instructions have been sent to your e-mail address.'));
$form_state['redirect'] = 'user';
return;
}
If there is a current language use it otherwise the user preferred. I have no clue why this was used but proofs you problem...
If I read your solution correct you want to override the forms submit and handle it yourself. I bet it works but I believe hook_mail_alter is our friend here and a smaller solution:
Comments
Comment #1
kars-t commentedHi dereine :)
I will look into this and maybe I can set a language so we can translate it through the mail_edit module. But the real translation of the email can only be done by mail_edit module as these are core mails and not translatable through core methods.
Comment #2
dawehneryes thats true, here is a short example code
i think this should work
Comment #3
kars-t commentedIf you look in line 2145 of the user.module
If there is a current language use it otherwise the user preferred. I have no clue why this was used but proofs you problem...
If I read your solution correct you want to override the forms submit and handle it yourself. I bet it works but I believe hook_mail_alter is our friend here and a smaller solution:
The user is an object in the params array and still here. So I load the preferred language and send the message.
I will test this now and make a new release if it works.
Comment #4
kars-t commentedimplemented in latest version