How to include username in reset password email

Hi everyone,

I have successfully altered the reset password body for my custom theme by adding a /email/messages/ file inside my theme with a passwordResetBody property in it.

I’m wondering if there is a way to include the user’s username in the reset password email they receive.

I know that the password-reset.ftl file is what generates the contents of the email.

And I know that the parameters passed in to msg() are used as positional parameters in the internationalization message passwordResetBody i.e. {0} is replaced with the value of link.

Is there a variable I could use such as username so that I could have a password-reset.ftl file in my theme that passes in an extra parameter like so?

<#ftl output_format="plainText">
${msg("passwordResetBody",link, linkExpiration, realmName, linkExpirationFormatter(linkExpiration), username)}

Hello tylervz, you can do

${msg("passwordResetBody",link, linkExpiration, realmName, linkExpirationFormatter(linkExpiration), user.username)}

and add {4} in your

You can also get username info or email by doing this :

Email: ${}
Username: ${user.username}
1 Like

Hi @AhmedBouk thank you for the response! The {4} placeholder in my message is not getting replaced, so it looks like my custom password-reset.ftl file is not being used. For my theme that is named mytheme, I have it placed in /themes/mytheme/email/text/password-reset.ftl . Is there something that I am missing?