Hello!
I have the following problem with CRED validation hook:
1. I placed the following code to functions.php (found in the plugin documentation):
add_filter('cred_form_validate','my_validation',10,2);
function my_validation($field_data, $form_data)
{
// field data are field values and errors
list($fields,$errors)=$field_data;
// print the field values
print_r($fields);
// validate if specific form
if ($form_data['id']==5020)
if ($fields['username']['value']!='correct_value')
// set error message per field
$errors['username']='Wrong Value';
// return result
return array($fields,$errors);
}
2. I made a cred form, with one filed, called 'username'
3. wp-config.php -> DEBUG true
4. I got the following error message in blank browser page, after submit form:
Array ( [username] => Array ( [value] => ergewfdsg [name] => username [type] => textfield [repetitive] => 0 [validation] => Array ( [required] => Array ( [active] => 1 [value] => 1 [message] => This field is required ) ) ) [form_submit_1] => Array ( [value] => Submit [name] => form_submit_1 [type] => submit [repetitive] => ) [_cred_cred_wpnonce] => Array ( [value] => 6e0523580d [name] => _cred_cred_wpnonce [type] => hidden [repetitive] => ) [_cred_cred_prefix_post_id] => Array ( [value] => 5114 [name] => _cred_cred_prefix_post_id [type] => hidden [repetitive] => ) [_cred_cred_prefix_form_id] => Array ( [value] => 5020 [name] => _cred_cred_prefix_form_id [type] => hidden [repetitive] => ) [_cred_cred_prefix_form_count] => Array ( [value] => 1 [name] => _cred_cred_prefix_form_count [type] => hidden [repetitive] => ) )
Notice: Undefined index: cred_form_5020_1_username in ..\wp-content\plugins\cred-frontend-editor\classes\Form_Builder.php on line 965
Fatal error: Call to a member function addError() on a non-object in ..\wp-content\plugins\cred-frontend-editor\classes\Form_Builder.php on line 965
I couldn't debug this error.
Thank You,
Tamás
Hi Tamás,
There is a known bug in current version of CRED, I am sending a development version of CRED with bug fix, please try and feedback if the problem is fixed.
Now it works fine!
Thank you!