This thread is resolved. Here is a description of the problem and solution.
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
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.