Estou tentando enviar e-mails aos usuários manualmente usando o gancho hook_mail_alter. A seguir, é minha função em sua totalidade:
function custom_module_mail_alter(&$message) {
$email = '[user:name],
A site administrator at [site:name] has created an account for you. You may now log in by clicking this link or copying and pasting it to your browser:
[user:one-time-login-url]
This link can only be used once to log in and will lead you to a page where you can set your password.
After setting your password, you will be able to log in at [site:login-url] in the future using:
username: [user:name]
password: Your password
-- [site:name] team';
$account = $message['params']['account'];
$uid = $account->uid;
$_user = user_load($uid);
dpm(token_replace($email, array('user'=>$_user)));
}
A saída é assim:
Peter,
A site administrator at Website has created an account for you. You may now log in by clicking this link or copying and pasting it to your browser:
[user:one-time-login-url]
This link can only be used once to log in and will lead you to a page where you can set your password.
After setting your password, you will be able to log in at http://localhost/website/user in the future using:
username: Peter
password: Your password
-- Website team
Como você pode ver, coisas como [usuário: nome], [site: nome] e [site: login-url] são processadas corretamente. O único token que não é processado é [user: one-time-login-url]. Alguma idéia de por que isso está acontecendo?
EDIT: Apenas para referência, o token é processado nos e-mails de boas-vindas enviados automaticamente pelo sistema, para que o módulo do token esteja ativo e funcionando ... Apenas não parece ser processado quando eu chamo manualmente token_replace ()