The code 'works' in a fashion, but it doesn't allow me to upload 'any' images.
It will spit out the error regardless of how many images I am uploading or not.
Here is an example of the code on my site;
add_filter('cred_form_validate','imagecheck',10,2);
function imagecheck($error_fields, $form_data)
{
//field data are field values and errors
list($fields,$errors)=$error_fields;
//uncomment this if you want to print the field values
//print_r($fields);
//validate if specific form
if ($form_data['id']==389 || $form_data['id']==238045)
{
//check my_field value
if (count($fields['wpcf-additional-images']) > 10)
{
//set error message for ls-photos
$errors['wpcf-additional-images']='Only a maximum of 10 images can be uploaded';
}
}
//return result
return array($fields,$errors);
}
Hello. Thank you for contacting the Toolset support.
Looking at the code, it looks ok to me but need to check whats going wrong with your setup.
Can you please share problem URL and admin access details and tell me how many images you want to allow users to be uploaded.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
I've adjusted the custom code you added as given under:
add_filter('cred_form_validate','imagecheck',10,2);
function imagecheck($error_fields, $form_data) {
//field data are field values and errors
list($fields,$errors)=$error_fields;
//uncomment this if you want to print the field values
//validate if specific form
if ($form_data['id']==1212 || $form_data['id']==238045){
//check my_field value
if (count($fields['wpcf-additional-images']['value']) > 2) {
//set error message for ls-photos
$errors['wpcf-additional-images']='Only a maximum of 2 images can be uploaded';
}
}
//return result
return array($fields,$errors);
}
Where the line adjusted is as follows:
if (count($fields['wpcf-additional-images']['value']) > 2) {