Skip to content

Instantly share code, notes, and snippets.

@pixelstorm
Created August 25, 2024 00:08
Show Gist options
  • Save pixelstorm/cf898784d5f224a7bebc511b43c36dc1 to your computer and use it in GitHub Desktop.
Save pixelstorm/cf898784d5f224a7bebc511b43c36dc1 to your computer and use it in GitHub Desktop.
Using a wordpress posts meta field for dynamic gravity form emails
<?php function agent_notification( $notification, $form) {
//This example is using a form with the id of 1
if($form["id"] == 4){
global $post;
//the example email is stored in a post meta field called "_cmb_email"
//$agent_email = get_post_meta( $post->ID , '_cmb_email', true );
$agent_email = get_field('agent_email');
$notification['to'] = $agent_email;
return $notification;
}
}
add_filter('gform_notification', 'agent_notification', 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment