Cannot replace {admin_email} merge tag

Hi, I’m trying to write an Add-on that will add a custom ‘admin email’ address which is used for Gravity Forms only, but I’m having trouble replacing the default {admin_email} merge tag results. I’ve tried using the gform_replace_merge_tags filter and the gform_pre_replace_merge_tags filter but neither seems to do the trick.

Looking in common.php I can’t find where any filter is actually being called that would allow for this - looks like pulling from WordPress’s default Administrator Email settings is fairly hard-coded. Am I missing something? This functionality is VERY needed and I’m happy to share the add-on with the community if I could get it to work!


Replacing the default output of a default merge tag is not recommended, instead it would be better to create your own merge tag. That’s the purpose of the gform_replace_merge_tags filter really.

If you really want to alter the output of a default merge tag, you will want to use this other filter: gform_merge_tag_filter - Gravity Forms Documentation

Using this filter, it’s up to your code to alter the default value or provide a new one.

I tried that one too, but it didn’t work. In common.php on lines 1233/1234 I see these comments which imply it’s not yet configured:

// TODO: Deprecate the 'gform_replace_merge_tags' and replace it with a call to the 'gform_merge_tag_filter'|
//$text = apply_filters('gform_merge_tag_filter', $text, false, false, false );|

The reason I want to edit the default {admin_email} merge tag is because it’s set as the default for Admin Notifications on all forms. My users, on dozens of sites, very seldom remember to go in and change those default notifications in any way, so it always uses the default site admin email (mine). I need to be the main site admin so I can remain responsible for plugin updates etc but I don’t want all the contact form stuff. Adding a global custom admin-email option for all GF forms to use seems like an easy solution.

Hi Michelle. I think I understand the issue: the {admin_email} merge tag is used by default as the TO and FROM address for all newly created notifications. You are the website admin, so you are getting unwanted emails from the forms when those emails should be going to (and from?) the site owners’ email addresses. Is that correct?

If you could default to a different merge tag for the TO and FROM for every new form notification, where would that merge tag get its email address from? I assume on dozens of sites that each site might have its own email address that should receive the form notifications?

For example, assuming you could redefine where {admin_email} gets its address, where would that come from instead?

Hi Chris! That’s exactly right.

In the Add-on I’ve been working on, I just added a setting/custom text field to store the alternate GF admin email address. If this could be built into GF core I’d expect that field to be on the main GF Settings page, but I had it in its own tab within the GF settings area.

I haven’t yet addressed the validation rules for the custom field (since I couldn’t get the proof of concept to work) but it would need to be validated as a single email address. If someone left the field empty, it would default to the way things work now, using the original site admin email as defined in Settings > General.

Michelle, for the use case described I would recommend you one of the following:

a) Set a custom default email address for the notification each time a new form is created. You can do this using the following filter: gform_after_save_form - Gravity Forms Documentation

Just change this line:

$notification['to'] = '';

You can find the documentation for the notification object here: Notifications Object - Gravity Forms Documentation

b) Override the notifications properties on the fly using this other filter: gform_notification - Gravity Forms Documentation

Thanks Samuel, I’ll do that. I have it working now setting a default ‘to’ and ‘from’ email (separately) via a new global settings tab, and it’s working great.

One more question - is there any built-in GF function for field validation in the settings area? I use the feedback_callback and a simple function (below) to validate my fields contain email addresses, but feedback_callback doesn’t prevent the form from being submitted nor does it show a textual error message. I do get the red X if someone enters an invalid email, but it’s still saved.

public function is_valid_setting( $value ) {
    return is_email($value);


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.