Route Notifications Via Username & Email

This is probably my new favorite code snippet for Gravity Forms!

Especially useful if you have several forms with multiple notifications each, this will allow you send to users of the site, rather than specific email addresses. Thus, if a user changes the email address associated with their account, the notification will follow suit. I hope to eventually write a blog post on the details of using it.

If you do put it to use, probably good to note that I may be kind of cheating the input validation for emails, which seems to accept text in the form of merge tags. Not sure if that could ever break saving of your notification in some future release.

2 Likes

You could also just use the user email merge tag in the email field ( {user:user_email} ). So if users do change their email, the notifications will always follow them.

The {user} merge tag identifies the user who is completing the form (see clarification by @richardw8k below), which is useful in some instances.

The script I link above allows identifying any user(s) on the site to which you’d like notifications sent.

1 Like

Ah - gotcha. Thanks for the resource!

1 Like

The {user} merge tag returns the values of the user logged in at the time they are processed. If notifications are re-sent at a later date/time they would be replaced with the details of the user who triggered the resend and not the user who originally submitted the form.

3 Likes