Skip to content

Instantly share code, notes, and snippets.

@nathaningram
Created December 16, 2024 17:10
Show Gist options
  • Save nathaningram/afc3bd0b68189bf01eaa2023bce34eef to your computer and use it in GitHub Desktop.
Save nathaningram/afc3bd0b68189bf01eaa2023bce34eef to your computer and use it in GitHub Desktop.
Site Info - GF Default Email - Starter Site 2024
//////////////////////////////////////////////////////////////////////////////
// Change Default GF Send To Email to the one in Site Info
//////////////////////////////////////////////////////////////////////////////
add_filter('gform_notification', function ($notification, $form, $entry) {
// Retrieve the replacement email from the Meta Box settings
$all_options = get_option('site-info');
$replacement_email = $all_options['bww_info_form_email'] ?? '';
// Validate the replacement email
if (!empty($replacement_email) && is_email($replacement_email)) {
// Check if the "Send To Email" field contains the {admin_email} tag
if (strpos($notification['to'], '{admin_email}') !== false) {
// Replace {admin_email} with the replacement email
$notification['to'] = str_replace('{admin_email}', $replacement_email, $notification['to']);
}
}
return $notification;
}, 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment