I am trying to: I have some validating to do with some custom coding and I am using this hook to check one of the fields against something before submission.
Link to a page where the issue can be seen: Local Development, including duplicator package.
I expected to see:
The hook firing upon edit form submission
Any edit of the moldflow submission forms were not firing the cred_form_validate hook. The one I was specifically playing with was cred form validate test 2. From the my account page is a link to view submissions. Then the links and edit links are there.
I set it up on a staging enviroment. In order to even see the post links and edit links you will need to login with credentials on the live staging site.
From what I see the hook isn't targetting a specific form.
Could you add an if statement so that its for a specific form like our example here ?
add_filter('cred_form_ajax_upload_validate','my_validation',10,2);
function my_validation($error_fields, $form_data)
{
//field data are field values and errors
list($fields,$errors)=$error_fields;
//validate if specific form
if ($form_data['id']==62)
{
//check if featured image exists o
if ($fields['_featured_image']['field_data']['size'] > 1000000)
{
//set error message for featured image
$errors['_featured_image'] = 'Wrong size image';
}
}
//return result
return array($fields,$errors);
}