Hi
I have a form that I use for user registration. (with help of Registration add-on)
I want to disable email validation for this form in a way that submitting duplicate email is possible.
I found this solution in the gravity documentation. it says that I should use this code along with another filter.
Ignore ‘This email address is already registered’ error returned by WordPress
If you want to allow users to register on your site using already registered emails, you will need to use the function below along with the gform_user_registration_check_email_pre_signup_activation filter.
add_filter( 'gform_user_registration_check_email_pre_signup_activation', '__return_false' );
add_action("gform_user_registration_validation", "ignore_already_registered_error", 10, 3);
function ignore_already_registered_error($form, $config, $pagenum){
// Make sure we only run this code on the specified form ID
if($form['id'] != 1) {
return $form;
}
// Get the ID of the email field from the User Registration config
$email_id = $config['meta']['email'];
// Loop through the current form fields
foreach($form['fields'] as &$field) {
// confirm that we are on the current field ID and that it has failed validation because the email already exists
if($field->id == $email_id && $field->validation_message == 'This email address is already registered')
$field->failed_validation = false;
}
return $form;
}
But it does not work for me. What I have done wrong here?