Prevent Multiple Form Entries
-
We are using the ‘Gravity Forms’ plugin but writing to a custom table in our database. Our database is titled ‘wp_dgptp’ and our table is titled ‘dg_application’.
We would like to prevent the user from submitting an entry twice. I.e. if the status is ‘Completed’ in the table then they should get a message telling them they can’t submit again. This is the code:
<?php if (get_current_user_id()) { //lookup current application: $query = "SELECT * FROM dg_application where user_id = " . get_current_user_id(); $dg_application = $wpdb->get_row( $query, ARRAY_A ); if ($dg_application["user_id"] && $dg_application["status"] == "Completed") { // custom field echo get_post_meta($post->ID, "form_complete_message", true); } else { //let Gravity Forms/WP do thier jobs while ( have_posts() ) : the_post(); // Include the page content template. get_template_part( 'template-parts/content', 'page' ); // End of the loop. endwhile; } } else { echo "Sorry. You must be logged in to view this form."; } ?> </main><!-- .site-main --> <?php get_sidebar( 'content-bottom' ); ?>
But unfortunately it’s not displaying the message and users are able to create another entry. Any ideas how to get it working?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Prevent Multiple Form Entries’ is closed to new replies.