Tell us what you are trying to do?
I would like to limit the number of photos allowed to be uploaded to 10
Is there any documentation that you are following?
I did use a support ticket found for code
Is there a similar example that we can see?
What is the link to your site? hidden link
You will need to log in to the site to get the form to load. I would also give you admin access so you can look at the Custom code snippet written for Toolset:
<?php
/**
* New custom code snippet (replace this with snippet description).
*/
toolset_snippet_security_check() or die( 'Direct access is not allowed' );
// Put the code of your snippet below this comment.
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']==174 || $form_data['id']==238045)
{
//check my_field value
if (count($fields['wpcf-all-listing-photos']) > 4)
{
//set error message for ls-photos
$errors['all-listing-photos']='Only a maximum of 4 images can be uploaded';
}
}
//return result
return array($fields,$errors);
}
The code runs but the count for the field is always 7 no matter how many images I add or how few.
Hello. Thank you for contacting the Toolset support.
Yes, can you please share admin access details.
*** 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.