【发布时间】:2018-01-31 07:20:35
【问题描述】:
我在这里遇到了障碍,我是一个新手编码器,也有点生疏。下面的代码在 wordpress 函数文件中完全有效,但我真的想从 CSV 文件验证而不是输入 2000 行来验证。
add_filter('frm_validate_field_entry', 'mobileform_custom_validation', 10, 3);
function mobileform_custom_validation($errors, $posted_field, $posted_value){
if($posted_field->id == 496){ //change 496 to the ID of the field to validate
if(!in_array($posted_value, array('001','002'))){ //change 001 and 002 to your allowed values
//if it doesn't match up, add an error:
$errors['field'. $posted_field->id] = 'Please contact us.';
}
}
return $errors;
}
【问题讨论】:
-
或者针对文本文件进行验证也可以。