Using WordPress meta field values for dynamic Gravity Form emails

Ever use Gravity Forms and want to easily add a form that takes an email value from the post? For example maybe you have store profile posts and each post has a contact form in the sidebar, but you want the email sent to each individual  person/store/whatever. Well there is a really simple way to do that.

function your_custom_notification_signature( $notification, $form) {

   //This example is using a form with the id of 1
    if($form["id"] == 1){
        global $post;

        //the example email is stored in a post meta field called "_cmb_email"
        $store_email = get_post_meta( $post->ID , '_cmb_email', true );
        $notification['to'] = $store_email;

       return $notification;
    }
}

add_filter('gform_notification', 'your_custom_notification_signature', 10, 3);

You can change a lot more than that as well, have a look at:

Advertisements

One thought on “Using WordPress meta field values for dynamic Gravity Form emails

  1. I’ve been using VirtualMin on my Digital Ocean droplets for a while, I find it’s a great way to get LAMP on several operating systems, and it’s a whole lot easier to set up HTTPS on CentOS than Ubuntu.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s