How to configure Gravity Forms to filter email

19 Views Asked by At

Hello all I'm working on a project that I could really use some help on.

It’s for a small law firm where each attorney has a bio page on the site. They want to have a contact form on each page that will send an email to that attorney. Rather than re-create the form 10x in GF, the form customization would be to add a filter that grabs the email address for the partner (which is in a postmeta field), and sends it to them directly.

Essentially this should be a single form that uses Gravity Forms filtering to determine who the Id/email address of the person whose page the user is on, and send it to them accordingly (instead of default WP admin notification).

This what I've tried so far but I need help getting it to work:

// GFORM_NOTIFICATION
add_filter( 'gform_notification', 'append_email', 10, 3 );
function append_email( $notification, $form, $entry ) {
        // get email address from hidden field w/ ID of 5
    $contact_email = $entry[5]; 
        // append email address to notifications objects
    $notification['to'] .= ', ' . $contact_email;
     return $notification;
}```
0

There are 0 best solutions below