Created
June 12, 2020 09:37
-
-
Save reachkamrul/f6a9033eebf50c9734f4ac8170307c63 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//Restrict repeated submission by user per day based on IP | |
add_action('fluentform_before_insert_submission', function ( $insertData, $data, $formId ) { | |
if($formId != 6) { // You can pass your form id here | |
return; | |
} | |
// IP based check | |
$last24Hours = date('Y-m-d H:i:s', time() - 24 * 60 * 60); | |
$isExist = wpFluent()->table('fluentform_submissions') | |
->where('form_id', $formId) | |
->where('ip', $insertData['ip']) | |
->where('created_at', '>', date('Y-m-d').' 00:00:00') | |
->first(); | |
if($isExist) { | |
wp_send_json(['errors' => [ | |
'restricted' => [ | |
'Sorry! You can not submit twice in a day. Try again tomorrow' | |
] | |
]], 422); | |
} | |
}, 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment