Limit one submission by logged user
-
Hi there!
I’m needing to limit submission in forms by one submission per logged user.
I found a snippet here in support that supposely works, but for me it isn’t. Here’s the snippet:
<?php add_filter( 'forminator_render_form_markup', function( $html, $form_fields, $form_type, $form_settings, $form_design, $render_id ) { if ( is_user_logged_in() ) { global $wpdb; $user_id_field_name = 'hidden-1'; $user_id = get_current_user_id(); $message = __( 'You can submit this form only once' ); $user_entries = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(e.entry_id) FROM {$wpdb->prefix}frmt_form_entry as e INNER JOIN {$wpdb->prefix}frmt_form_entry_meta as m ON e.entry_id=m.entry_id WHERE m.meta_key=%s AND m.meta_value=%d LIMIT 1", $user_id_field_name, $user_id ) ); if ( ! empty( $user_entries ) || 0 < $user_entries ) { return $message; } } return $html; }, 10, 6 );
This snippet is found in this thread: https://www.ads-software.com/support/topic/limit-submission-by-user/
My problem is that right now this snippet is locking every logged user for every form in my site, regardless if the form have the ‘hidden-3’ filed set to user id or not.
Please, can you guys help me to solve it? TIA
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Limit one submission by logged user’ is closed to new replies.