HI Christian
Thanks for that, I'll give it a whirl now. We have 9 taxonomies on the same form, 6 of which we would we would like to ensure are non-null on submission.
1) Can I check all 6 in one script, or do I have to repeat this entire code 6 times?
I am imagining I could just repeat the one snippet of code in between, here's my draft:
function validate_nanny_ad_submission($field_data, $form_data) {
// Split $field_data into separate $fields and $errors
list( $fields,$errors ) = $field_data;
// validate New Native Nanny Ad Form (ID: 921)
if ( $form_data['id']==921) {
// check at least one of Available Day taxononmy term set
if ( empty( $fields['available-days']['value'] ) ) {
$errors['available-days'] = 'Please select at least one value for AVAILABLE DAYS.';
}
}
// check at least one Native Language taxonomy term set
if ( empty( $fields['native-language']['value'] ) ) {
$errors['native-language'] = 'Please select at least one value for NATIVE LANGUAGES.';
}
}
// check at least one Time of Day taxonomy term set
if ( empty( $fields['time-of-day']['value'] ) ) {
$errors['time-of-day'] = 'Please select at least one value for TIME OF DAY.';
}
}
return array($fields,$errors);
}
add_filter( 'cred_form_validate', 'validate_nanny_ad_submission', 10, 2 );
2) How can I ensure that the messages "Please select at least one value for ......" are translatable? Does [wpml_string] work inside PHP code?
Thanks and best regards
Simon