I have a cred validation hook to restrict the size & type of image files uploaded on the frontend. The Media Library checkbox on form is unchecked :-
add_filter('cred_form_validate', 'ts_validate_data_222',10,2);
function ts_validate_data_222($field_data, $form_data){
$form_ids = array( 222 => true );
list($fields,$errors)=$field_data;
if ( isset( $form_ids[ $form_data['id'] ] ) ) {
if ( !empty( $fields['wpcf-logo']['value'] ) ) {
$file_type_logo=$fields['wpcf-logo']['file_data']['type'];
$file_size_logo=$fields['wpcf-logo']['file_data']['size'];
if ( ( $file_type_logo != 'image/jpeg' ) || ( $file_size_logo > 10240 ) ) {
$errors['logo'] = 'Please check your image is a JPG/JPEG and smaller than 10KB in size';
}
}
}
return array($fields,$errors);
}
I've not had any issues with uploading files for ages but now, if the image fails the validation, several thing shappen:-
1. a Toolset generated notice "Because validation failed, please upload the files again" appears
2. the word "Array" is displayed instead of the cred field, and the "choose file" button only shows if the user manually clicks on the X
3. my debug log has these entries:-
"Warning: md5() expects parameter 1 to be string, array given in /home/xxxx/public_html/wp-content/plugins/cred-frontend-editor/application/models/field/wptoolset/class.abstract_credfile.php on line 144
Notice: Array to string conversion in /home/xxxx/public_html/wp-includes/formatting.php on line 1098
Notice: Array to string conversion in /home/xxxx/public_html/wp-includes/formatting.php on line 1098
Notice: Array to string conversion in /home/xxxx/public_html/wp-includes/formatting.php on line 1098
Notice: Array to string conversion in /home/xxxx/public_html/wp-content/plugins/cred-frontend-editor/vendor/toolset/toolset-common/toolset-forms/classes/class.eforms.php on line 598
Notice: Array to string conversion in /home/xxxx/public_html/wp-content/plugins/cred-frontend-editor/vendor/toolset/toolset-common/toolset-forms/classes/class.eforms.php on line 598
Notice: Array to string conversion in /home/xxxx/public_html/wp-includes/formatting.php on line 1098"
Several questions arise out of this:-
1. how do I either prevent generation of the Toolset message (I have already covered this requirement elsewhere on the form, your format just doesn't fit with my design nor does it appear where I want it to) OR how do I hide it?
2. What's the issue causing the errors?
3. Is this a known issue?