Last active
June 22, 2020 12:05
-
-
Save alex-authlab/3a52d17f39b05353def46bee7a60c062 to your computer and use it in GitHub Desktop.
Prevent submission with duplicate email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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