[Resuelto] Need to validate unique mail values in post field
This support ticket is created hace 1 año, 2 meses. 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.
Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.
Sun
Mon
Tue
Wed
Thu
Fri
Sat
-
10:00 – 13:00
10:00 – 13:00
10:00 – 13:00
10:00 – 13:00
10:00 – 13:00
-
-
14:00 – 18:00
14:00 – 18:00
14:00 – 18:00
14:00 – 18:00
14:00 – 18:00
-
Supporter timezone: Asia/Kolkata (GMT+05:30)
Este tema contiene 7 respuestas, tiene 3 mensajes.
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:
- enlace oculto
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.