Skip to content

Instantly share code, notes, and snippets.

@nathaningram
Created October 14, 2024 14:46
Show Gist options
  • Select an option

  • Save nathaningram/16800830604c644372f0fe0638db51e1 to your computer and use it in GitHub Desktop.

Select an option

Save nathaningram/16800830604c644372f0fe0638db51e1 to your computer and use it in GitHub Desktop.
Replace Gravity Forms {admin_email} with [email protected]
// Replace GF {admin_email} tag with website email
add_filter( 'gform_notification', 'bww_change_from_email', 10, 3 );
function bww_change_from_email( $notification, $form, $entry ) {
// Get the site's domain dynamically
$site_url = parse_url( get_site_url(), PHP_URL_HOST );
$custom_admin_email = 'website@' . $site_url;
// Check if the notification 'from' email is using {admin_email}
if ( isset( $notification['from'] ) && $notification['from'] === '{admin_email}' ) {
$notification['from'] = $custom_admin_email;
}
return $notification;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment