Created
October 14, 2024 14:46
-
-
Save nathaningram/16800830604c644372f0fe0638db51e1 to your computer and use it in GitHub Desktop.
Replace Gravity Forms {admin_email} with [email protected]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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