Including a member first/surname in any email

AI-generated summary

The discussion revolves around including a member’s first name, surname, or username in an email using Discourse. roshni.duttagupta initially asked if this was possible, and pfaffman suggested using %{username}. However, when BobbyZopfan tried to use this in the welcome email, they encountered an error indicating that the interpolation key “username” was invalid. zogstrip and gerhard explained that certain interpolation keys are not available in all email templates due to translation and performance concerns. gerhard suggested extending the existing functionality to allow certain interpolation keys for all user_notifications.user_ translations, which could potentially resolve the issue.

Hi!
Is there a way to include a member’s first name, surname or username in an email?

Hi,

Thanks for the reply:)

Actually I was thinking of something like this:

Suppose my member’s name is Rebecca, I want my email to look like:

"Dear Rebecca,

Thanks for…"

Is there any any way to get this done?

Thanks

The username should be
%{username}

There are other topics about customizing emails with other examples

When I add this field in the welcome email (in other words, I, being the admin, when I edit the welcome email text and add this %{username} at the beginning of the email, it gives an error to the effect that:
Body: The following interpolation keys are invalid: “username”.

What does this error mean and how to overcome it?

It means that the interpolation “%{username}” is not available for that string.

Can you be more specific?

As to what steps need i to take to resolve it?

It means you can’t use “%{username}” in that text since it won’t be interpolated.

But @pfaffman is saying above that

The username should be
%{username}

Do you mean that we can’t address a user by his name thru a template?

So there’s some kind of bug here since you’ll never be able to use an interpolation that isn’t already available in the default english text. Even though we might have the code to allow you to use that interpolation.

@gerhard do you think it would be worth adding support for some default interpolations that would be available everywhere?

Everywhere? No. That has potential to break a couple of translations, because the i18n gem does different things when I18n.t is called with interpolation values. And it adds a small performance penalty. I wouldn’t want to go down that road.

But, we could extend the existing functionality that already allows certain interpolation keys for all user_notifications.user_ translations even though they do not exist in the English strings.

I meant everywhere in email templates.