When trying to submit on this form, the following error have popped up. Shouldn’t the form_id be grabbed automatically by Gravity Forms?
Other forms we have does not have this issue.
To add to the above comment, the following validation php is set to this form:
add_filter( 'gform_validation_23' , 'for_form23');
function for_form23 ($form){
$id = rgpost("input_3");
$requester_ip = rgpost("input_5");
$requester_name = rgpost("input_6");
GFCommon::log_debug(__METHOD__."(): id {$id}");
GFCommon::log_debug(__METHOD__."(): ip {$requester_ip}");
GFCommon::log_debug(__METHOD__."(): name {$requester_name}");
$admins = array(*list of admins*);
foreach ($admins as $admin){
if ($requester_name == $admin){
GFCommon::log_debug(__METHOD__."(): admincheck {$admin}{$requester_name}");
$is_admin = 0;
break;
}
else $is_admin = 1;
}
if ($is_admin == 0){
//Something here
}
else if ($is_admin ==1){
$form['is_valid'] = false;
//finding Field with ID of 1 and marking it as failed validation
foreach( $validation_result['fields'] as &$field ) {
//NOTE: replace 1 with the field you would like to validate
if ( $field->id == '6' ) {
$field->failed_validation = true;
$field->validation_message = 'Field Invalid';
break;
}
}
}
$form['form'] = $validation_result;
return $form;
}
The filter param and return value are incorrect. Try this:
add_filter( 'gform_validation_23' , 'for_form23');
function for_form23 ($validation_result){
$form = $validation_result['form'];
$id = rgpost("input_3");
$requester_ip = rgpost("input_5");
$requester_name = rgpost("input_6");
GFCommon::log_debug(__METHOD__."(): id {$id}");
GFCommon::log_debug(__METHOD__."(): ip {$requester_ip}");
GFCommon::log_debug(__METHOD__."(): name {$requester_name}");
$admins = array(*list of admins*);
foreach ($admins as $admin){
if ($requester_name == $admin){
GFCommon::log_debug(__METHOD__."(): admincheck {$admin}{$requester_name}");
$is_admin = 0;
break;
}
else $is_admin = 1;
}
if ($is_admin == 0){
//Something here
}
else if ($is_admin ==1){
$validation_result['is_valid'] = false;
//finding Field with ID of 1 and marking it as failed validation
foreach( $form['fields'] as &$field ) {
//NOTE: replace 1 with the field you would like to validate
if ( $field->id == '6' ) {
$field->failed_validation = true;
$field->validation_message = 'Field Invalid';
break;
}
}
}
$validation_result['form'] = $form;
return $validation_result;
}