Last active
August 31, 2022 11:32
-
-
Save slaFFik/52af17ae7a524997647de432bd21f353 to your computer and use it in GitHub Desktop.
WPForms: Submit the form only once for logged in users.
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
<?php | |
add_action( 'wp', function () { | |
if ( ! is_user_logged_in() ) { | |
return; | |
} | |
$entries = wpforms()->entry->get_entries( | |
array( | |
'form_id' => 74, // CHANGE THIS FORM ID | |
'user_id' => get_current_user_id(), | |
), | |
true // count values only, we don't need actual data | |
); | |
// We allow to fill the form only once. | |
if ( $entries >= 1 ) { | |
add_action( 'wpforms_frontend_output_before', function () { | |
echo '<p>You have already submitted this form.</p>'; | |
} ); | |
add_action( 'wpforms_frontend_load', '__return_false' ); | |
} | |
} ); |
hi,
I tried this code in three wp code snippet plugins, but in all of them, one form can be sent multiple times. Or it locks other forms and does not allow sending other forms
please guide me.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi,
I tried this code in three wp code snippet plugins, but in all of them, one form can be sent multiple times.
please guide me.