Sauter la navigation

[Résolu] Help for Validation cred form featured image

This support ticket is created Il y a 4 années et 9 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Ce sujet contient 1 réponse, a 2 voix.

Dernière mise à jour par Luo Yang Il y a 4 années et 9 mois.

Assisté par: Luo Yang.

Auteur
Publications
#1640109

lien caché

Hallo,

i have problems with validation in my cred form. I want to check, if a featured image will be uploaded.

My form-field looks like this:

<div class="form-group">
<label>Bild der Aktivität (Pflichtfeld)</label>
[cred_field field="_featured_image" force_type='field' class="form-control" output="bootstrap" class='wpcf7-form-control wpcf7-text' required='true']
</div>

After looking into your technical-support-site i have inserted this code into the functions.php. The id of my form is 5700.

add_filter('cred_form_validate','my_validation',10,2);
function my_validation($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']==5700)
{

//check if featured image exists
if (empty($fields['_featured_image']['value']))
{
//set error message for featured image
$errors['_featured_image'] = 'Missing featured image';
}
}
//return result
return array($fields,$errors);
}

My Problem: The field for featured image is checked and i can't submit the form.

But there is no text like "missing picture".

What can i do?

#1640999

Hello,

The problem you mentioned above is abnormal, the filter hook "cred_form_validate" works in server side before store into database, it won't prevent you from submitting the form.

I suggest you check these:
1) Make sure you are using the latest version of Toolset plugins, you can download them here:
https://toolset.com/account/downloads/

2) In case it is a compatibility problem, please deactivate all other plugins, and switch to wordpress default theme 2020, deactivate all custom PHP/JS codes, and test again

3) Also check if there is any PHP/JS error in your website:
https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/