SOLUTION: Append the original URL to Gravity Forms notifications automatically
Most developers who use Gravity Forms have had this situation come up at some point. You get a Gravity Form email notification and you have no idea which website it came from! This can happen when your email is set as the administrative email on the Settings > General page because Gravity Forms defaults to using that address for new form notifications. Unless your client manually changes it, you may get all the email notifications and not know what website they came from. This happened to me recently and so I created this code snippet to fix it.
The premise behind the code snippet is simple – use Gravity Forms’ own hook and merge tags to append the original URL to Gravity Forms notifications automatically.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
/* * Automatically append the URL from which the Gravity Forms form was submitted */ add_filter( 'gform_notification', 'gforms_notification_add_entry_url', 10, 3 ); function gforms_notification_add_entry_url( $notification, $form, $entry ) { if ($notification['message_format'] == 'text') $notification['message'] .= "Submitted from {embed_url} on {date_mdy}"; else $notification['message'] .= "<br /><br />Submitted from <a href='{embed_url}'>{embed_url}</a> on {date_mdy}"; return $notification; } |
Voilà! The original URL is appended to the Gravity Form notification. Add this code to all your sites going forward and you will never have to worry about this situation again.
What do you think?