Our team is trying to localize our email templates as suggested here:
We’ve added an auth0 rule to add the user’s language to the user_metadata upon signup, which appears to work correctly. We’ve added {% debug %} to our email templates to ensure the language is coming through successfully in the user_metadata on all our email templates which it does - except for the Verification Email.
Is user_metadata not passed in with the Verification Email? We see the user field, but not the user.user_metadata field.
@adam.rehill This is happening because rules are run during login, and the verification email is sent just after signup - rules don’t have a chance to run before that.
One option would be to set the metadata in a pre-registration hook:
The metadata you set there will be available in the verification email.
@thameera Thanks for the suggestion, this does seem to work as far as updating user_metadata before the email gets sent, however we don’t have access to the same context field as we do on rules. We are using context.request.query to access the language we tack on during signup. context.request.query is not available in the pre-registration hook.
I also tried context.requestLanguage but this seems to be the browser’s accept-language header which is not the same thing.
Another option would be to send the language during the signup, so it will automatically become a part of user’s user_metadata (instead of sending it via a query param).
If you’re using Auth0 Lock, this can be sent using additionalSignupFields for example:
@thameera Why context.request.query is not accessible ? It will be so simple to get the language from the url.
In a nutshell, to set an app language to the user metadata, we are forced to add an additionnalField and implement “Progressive Profiling” for SSO (google/facebook …) ?
OMG. This post is exactly what I was looking for. Everything works great except the the verification email because I set the user_metadata language in a Rule, which is too late (the Verification email is sent after that). I have tried the very other things above.
@thameera I tried that last solution, but couldn’t make it work yet:
1)Passing “user_metada” is super easy with the Auth0.js, but I use Lock and the only way possible to send user_metadata is by creating an additional field ( additionalSignupFields), but this field is only for Database connections, right?
2) Hooks would help me a lot, but it only works for Database Connections: again, social connections won’t apply
My question is: How can I pass user_metadata on signup for Social connections? All solutions dont seem to work for Social Connections.