如何验证复选框以在 wordpress 联系表单 7 中仅选择一个?我在functions.php中编写了以下代码
function custom_cf7_required_check_filter($result, $tag) {
$val = $_POST['Yes'];
$opts = strpos($val, ",");
if($opts != false){
$result['reason']['Yes'] = "True";
}else{
$result['reason']['Yes'] = "False";
}
return $result;
}
add_filter('wpcf7_validate_checkbox', 'custom_cf7_required_check_filter', 10, 2);