-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
user.preferredLanguage variable not available in Sprout Email 4.x #322
Comments
Any hint on this one? |
@medoingthings The main things that changed here is that when moving to Craft 4, what once was a single User Save Notification event trigger is now two different events:
And the event we trigger off of used to be I'm not sure why this was working before, but I think the main issue here is that the user language preference does not get saved until after the user is saved (so the information is not present when the email event fires) and also, a new user is not logged in, and it appears the language preference only gets saved if a Right now, I think the best thing you have to go on is the site language
Or perhaps trying to grab the value you posted in the form directly in the template:
I am seeing values for the If you'd like to tell me a bit more about which specific event you are using and what event/code you are using to trigger the email where you are seeing this issue I'm happy to try to consider options to better support this. I think checking for the posted param in the template might be the easiest path forward for now. |
Found the time to give it a go… Using The remaining issue is, how do I know which language to pick for the email that is triggered by the I understand now, that Craft doesn’t set the So… what do I do? Any chance that I can store the value with Sprout Email? |
Description
I use a front-end form to register new users in Craft. It’s a multi-site website, which is why I set preferredLanguage on the form:
In the Craft 3.x version of Sprout Email, I was able to use
user.preferredLanguage
to…{preferredLanguage == 'de' ? 'Willkommen' : 'Welcome'}
This seems to have stopped working after upgrading to Craft 4. When I use
{{ currentUser.preferredLanguage }}
in a regular template on any page for a newly created front-end-user, I get a correct country code likeen
.But when I use
{{ user.preferredLanguage }}
in the email template or in the notification config for the subject line, it’s empty.Any hint how to get back the functionality?
How to reproduce
preferredLanguage
variable is set for a user{{ user.preferredLanguage }}
within the triggered notification emailSprout Version
4.44.444-beta.9
Craft Version
4.8.10
Database Type Version
MySQL 5.7.39
The text was updated successfully, but these errors were encountered: