Skip to content

Instantly share code, notes, and snippets.

@alex-authlab
Last active June 22, 2020 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alex-authlab/3a52d17f39b05353def46bee7a60c062 to your computer and use it in GitHub Desktop.
Save alex-authlab/3a52d17f39b05353def46bee7a60c062 to your computer and use it in GitHub Desktop.
Prevent submission with duplicate email
/*
* Unique email vaildation
*/
add_action('fluentform_before_insert_submission', function ( $insertData, $data, $formId ) {
if($formId->id != 100) { // You can pass your form id here
return;
}
// Email based check
$isExist = wpFluent()->table('users')
->where('user_email', $data['email']) // make sure your email input name attibute is - email
->first();
if($isExist) {
wp_send_json(['errors' => [
'restricted' => [
"Sorry! there are already an account registered with your email."
]
]], 422);
}
}, 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment