I’m currently building a page with a drop-down menu containing a list of contacts, and upon selecting a contact, I’d like to have a single Gravity contact form populated with that email address for sending a notification (rather than creating numerous separate forms, each hard-coded to notify a given email address.) My hope is that I can populate a hidden form field via jQuery w/ the contact email (pulled from the select menu value), and then instruct Gravity forms to send a form notification w/ form data to the selected email address. From reviewing the docs and other threads here, it appears I can use the gform_pre_submission_filter
in a way like the following (?)
add_filter('gform_pre_submission_filter', 'add_email_notify');
function add_email_notify( $form ) {
$form['fields'][ID] = $form['notifications']['routing']['email']; // reference ID of hidden field w/ JS-populated email address
// return the modified form object
return $form;
}
The ID
would reference the ID of the hidden form field-- is this approach correct? I’ve also seen suggestions related to creating a hidden field w/ parameter name and referencing that parameter to get a field populated with the email address, but I’m not sure of the best route. Thanks for any insight here!