Tell us what you are trying to do?
im trying to build a membership site, now have the respective products and membership yet, but i have a trouble with validation of unique email, that is not work,
the steps of register is:
-create an account
-log in
-send form for register a new entry of "base de datos" custom post
the entry must be unique for each of the users, and must be validated by the email field
Is there any documentation that you are following?
Hello. Thank you for contacting the Toolset support.
Have you tried the validation hook shared with the reference ticket you shared?
If yes - what issue you are facing?
- have you also tried to replace the form ID and your custom field slug as well as post type?
Can you please share bit more details where exactly you stuck and where you need help with and problem URL and admin access details.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
I've adjusted the code snipped as given under:
- hidden link
add_filter('cred_form_validate','func_validate_custom_email',10,2);
function func_validate_custom_email($error_fields, $form_data){
//field data are field values and errors
list($fields,$errors)=$error_fields;
if ($form_data['id']==54610){
$args = array(
'meta_query' => array(
array('key' => 'wpcf-email-bd',
'value' => $_POST['wpcf-email-bd']
)),
'post_type' => 'base-de-datos-alas',
'post_status' => array('publish', 'pending', 'private'),
'posts_per_page' => -1
);
$posts = get_posts($args);
if (count($posts) > 0){
//set error message for my_field
$errors['wpcf-email-bd']='This E-mail already registered.';
}
}
return array($fields,$errors);
}
The reason why it was not working because you have a private posts and by default get_post function checks and return the publish posts. So I've added the post status argument to get_post argument as you can see with the above code:
As per our support policy, we entertain only one question per ticket. This will help other users searching on the forum as well as help us to write correct problem resolution summery for the original question reported.
May I kindly ask you to open a new ticket with every new question you may have. That would be really helpful.