CRED plugin provides an API, making it easy to customize your post or user forms. The API includes hooks (actions and filters) to accomplish specific tasks using PHP code.
When you ask for help or report issues, make sure to tell us all related information about your form and what you want to achieve.
Viewing 15 topics - 196 through 210 (of 356 total)
Problem: I am trying to validate a custom field with cred_form_validate, but I cannot validate a specific field. Errors never appear in the form.
Solution: Be sure to include the form_messages field in the Form builder so errors can be displayed. Then use the following syntax to validate a custom field:
function fn_cred_form_validate($error_fields, $form_data)
{
list($fields,$errors)=$error_fields;
if ($form_data['id']==221) {
if (empty($fields['wpcf-application-tour-number']['value'])) {
//set error message for my_field
$errors['application-tour-number']='Please select tour first';
}
}
return array($fields,$errors);
}
add_filter('cred_form_validate','fn_cred_form_validate',10,2);
Notice that the wpcf- prefix is required in the $fields array, but should not be included in the $errors array.
Problem: I have defined a custom field in my Form and set its value using a URL parameter. I would like to hide that field on the front-end, but if I use HTML comments the field value is not saved. How can I hide the field but save the value from a URL parameter?
Solution: Use CSS to hide the field itself or a container element: