I have a hook here which works great (it looks for a field with the parameter name zip, and sets a hidden field based on the zip value):
[php]
add_action("gform_pre_submission", "set_email_notification_flag", 10, 2);
function set_email_notification_flag($form){
//search for zip label and notification flag
$formfieldzip="";
$formfieldnotificationflag="";
foreach($form['fields'] as $k=>$v)
{
if($form['fields'][$k]['inputName']== "zipcode") $formfieldzip= "input_". $form['fields'][$k]['id'];
if($form['fields'][$k]['inputName']== "emailnotification") $formfieldnotificationflag= "input_". $form['fields'][$k]['id'];
}
if ( ($formfieldzip!="")&&($formfieldnotificationflag!="")) {
$zipcode = $_POST[$formfieldzip];
$_POST[$formfieldnotificationflag]=zipcodearea($zipcode);
}
}
Now I have another hook for a specific form. This time I am trying to access the zipcode field of the address type advanced field.
[php]
add_action("gform_pre_submission_14", "set_email_notification_flag_14", 10, 2);
//specific email notification form 14
function set_email_notification_flag_14($form){
$formfieldzip="input_19.5";
$formfieldnotificationflag="input_25";
$zipcode = $_POST[$formfieldzip];
$_POST[$formfieldnotificationflag]=zipcodearea($zipcode);
}
I find that I cannot access the zipcode value (the variable is empty). The same holds for all the sub fields of any of the advanced field types. I cannot lay a finger on what I am doing wrong. Thanks.