Ce fil est résolu. Voici une description du problème et la solution proposée.
Problem:
I would like to have featured image as a required field in CRED form.
Solution:
Add following code in theme’s functions.php file:
function my_validation($field_data, $form_data)
{
list($fields,$errors)=$field_data;
if ($form_data['id']==488) //change form ID
{
if (empty($fields['_featured_image']['value']))
{
$errors['_featured_image'] = 'Missing featured image';
}
}
return array($fields,$errors);
}
add_filter('cred_form_validate','my_validation',10,2);
Also check that there should be no php errors and syntax mistakes in theme’s OR Child theme’s functions.php
This support ticket is created Il y a 7 années. 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.
Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.
Thank you for contacting Toolset support. I have checked the code you have provided, and it is working as expected.
- Please double check the form ID.
- Please try to check it by deactivating all third-party plugins (except Toolset) and switching back to the Default Theme (e.g. Twenty Sixteen theme) to see for any possible conflicts with any of the plugins or themes?
- If still issue arise, please provide temporary access (WP-Admin and FTP Login info) to your staging site.
Your next answer will be private which means only you and I have access to it.
=== Please backup your database and website ===
✙ I would additionally need your permission to de-activate and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important.
✙ Please add the Links to the [CRED Form] Edit Screen and [Page] Edit Screen where you have inserted this Form.
There were some php errors and syntax mistakes in Child theme’s functions.php. I have fixed the below code and now featured image is made as required on both forms.