Including a member first/surname in any email

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

3 Likes

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?

1 Like

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

1 Like

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.

1 Like

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?

2 Likes

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.

https://github.com/discourse/discourse/blob/1852a95a41a9522d0ab29aa678dc4012c8f625dd/app/models/translation_override.rb#L4-L11

2 Likes

I meant everywhere in email templates.

2 Likes