The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

users entry cannot be have same value

Labels

This Discussion is public

Notifications

I have found this code that look is the email has been registered with another user. I want to do the same thing but use a normal text field and then validate that no other user has submitted the same value. can I modify this code and use it?

add_filter('frm_validate_field_entry', 'maybe_redirect', 10, 3);
function maybe_redirect( $errors ){
if ( isset( $errors['field'. 71 ]) && $errors['field'. 71 ] == 'This email address is already registered.' ) { //change 799 to your email field id
wp_redirect('http://www.google.com'); //change the url to the URL you want users redirected to
exit;
}
return $errors;
}

The may be the right hook, but the code you see in the example is specifically for user registration when the user registration add-on is installed. In this example, the registration add-on is checking for duplicate registrations. This example is not doing the duplicate check.

There aren't any examples on the knowledgebase page that will get you there.

Hooks like this one run on the server, which means you won't see errors until the submit button is pressed. If you want the check to take place in real-time while the user is entering the data into the field, you need to use jQuery and Ajax.

Whichever way you decide to go, it's going to require custom code.

Discussion closed.