Can we add site name or site URL to the default notification? [RESOLVED]

Hi there!

We manage a ton of sites for our clients and often when we or they set up a form we forget to disable the default Admin notification.

This means we get an email with “New submission from {form_title}” - however we have absolutely no idea of which site the form is actually being sent from.

Would it be possible to set the default notification to be “New submission from {site_name}: {form_title}” or alternatively have the main content to show:
{all_fields}
via: {embed_url}

Cheers,
.: Tore

You could use a custom function to add site-info to the all_fields contents automatically:

Or use a custom notification template:

Or filter the message-data of the notification (which can be used to change the subject, ie. to add the site-name):

1 Like

Looks like that’ll do the trick for us for now, cheers. We will have to implement it on a ton of sites, but that’s our headache.

1 Like

Here’s the code I use for custom merge tags. Makes use of the gform_replace_merge_tags filter, not linked above. I currently have both {site_url} and {site_name} as options.

1 Like

Sweet! We’ll definitely have a closer look at that. Makes perfect sense just skimming it. Thanks a bunch :slight_smile:

1 Like

Hi Joshua,
I tried your code in both, functions.php of the theme and also creating a new file under the GF folder that I named " gf-custom-merge-tags.php" as I noticed you did but none of those case scenarios resulted in seeing the Site Name or Site URL in the drop-down options under the Notifications settings, am I missing other steps or something else?

This code only makes them available for use. It doesn’t explicitly add it to the dropdown. The full code, both for powering the merge tags and getting them listed w/in the dropdown can be found here:

AH! Thank you Joshua! The code worked once added to the theme’s functions.php file, but let’s say we wanted a more centralized location to host these mods such as in that “gf-custom-merge-tags.php” file, or was this strictly a custom approach you setup on your end?

I bookmarked that awesome snippets page full of neat mods :slight_smile:

1 Like

gform_default_notification - Gravity Forms Documentation will never forget for you :slight_smile:

3 Likes

UPDATE: Issue confirmed due to GF 2.5 and PHP 8.0, I reverted back to Php 7.4 and GF 2.4 for now until things settle :slight_smile:

I just updated to GF 2.5 and this snippet no longer works, furthermore I was getting the following warnings on the front-end wherever a GF form was loaded: “Warning: Trying to access array offset on value of type bool in…” pointing to the theme’s functions.ph file where I placed the snippets.
I downgraded the Php version of the site from 8 to 7.4, the warnings are gone, but still no merge tags showing up in the drop-downs.

Just to help isolate if the issue is on my end or not, can someone please validate the compatibility with GF 2.5? Otherwise I think I will revert back to GF 2.4 and wait for a more stable version.

Date/Timestamp/Site URL and Site Name no longer appear in the drop-down :frowning:

Hi FanaticWeb - I recommend opening a support ticket if you need assistance with this issue.

Thank you.

@FanaticWeb I’ve updated the script on snippet.farm to work with Gravity Forms 2.5. The previous code was improperly using an available GF filter to print content to the page. The current code shown takes a more reliable approach.

1 Like