Hello GF Support!
Wonderful product! Thank you! I've searched the forums, and have not found an answer to my issue. On my contact form are two radio buttons. Depending on what a user selects in those two radio buttons, the email would be routed to a different email address with a custom subject line. I cobbled together some code based on reading other GF documentation and forum responses, and using the editor in the WP admin area, I pasted this code in my functions.php file, and when I updated the file I got the error message in the subject line. Here is my code:
add_filter('gform_pre_submission_filter_1', 'modify_sendto_subject');
function modify_sendto_subject($form){
// my form uses input_1 for the select box. Your form may be different. Change it here as necessary
$input_field_1 = 'input_1_1';
$input_field_5 = 'input_1_5';
// clear out any default Send To email addresses or subject lines from the form builder
$to = '';
$subject = '';
// Check the form submission for the radio buttons. If there is a value in $input_field_1, then modify the Subject line and the Send To email address
if (isset(rgpost($input_field_1)))
{
// rgpost is a safe way of accessing the $_POST values
if (rgpost($input_field_1) == "Loans")
{
$to = 'emailname1@email.com';
$subject = 'Online Contact Form - Loans';
}
if (rgpost($input_field_1) == "General Banking")
{
$to = 'emailname2@email.com';
$subject = 'Online Contact Form - General Banking';
}
if (rgpost($input_field_1) == "Web")
{
$to = 'emailname3@email.com';
$subject = 'Online Contact Form - Web';
}
}
// If no value was selected for the first radio button, then modify the Subject line on whether or not a location preference was or was not selected
if (!isset(rgpost($input_field_1)))
{
if (!empty(rgpost($input_field_5)))
{
$to = 'emailname4@email.com';
$subject = 'Online Contact Form - No Subject Selected - Look at Location Preference';
}
if (rgpost($input_field_5) == "" || rgpost($input_field_5) == NULL)
{
$to = 'emailname5@email.com';
$subject = 'Online Contact Form - No Subject Selected - No Question or Location Preference';
}
}
// return the modified form object
return $form;
}
Is my code bad? Is there a form setting I need to enable (or disable)? If necessary, here is a link to the form: http://dev.coolwatercreative.com/isb/contact-us/phone-numbers-email/
Thank you!