{"id":4344,"date":"2024-04-01T20:10:05","date_gmt":"2024-04-01T18:10:05","guid":{"rendered":"https:\/\/www.knowboard.de\/?p=4344"},"modified":"2024-04-01T20:10:09","modified_gmt":"2024-04-01T18:10:09","slug":"forminator-prevent-multiple-submissions-from-same-email","status":"publish","type":"post","link":"https:\/\/www.knowboard.de\/forminator-prevent-multiple-submissions-from-same-email\/","title":{"rendered":"Forminator: Prevent multiple submissions from same email"},"content":{"rendered":"\n
add_filter('forminator_custom_form_submit_errors', function( $submit_errors, $form_id, $field_data_array ) {\n global $wpdb;\n\n \/\/ Retrieve the email value from the form field\n $form_email = $field_data_array[1]['value'];\n\n $sql = $wpdb->prepare(\n \"SELECT COUNT(*)\n FROM {$wpdb->prefix}frmt_form_entry_meta\n WHERE meta_value = %s\",\n $form_email\n );\n\n $results = $wpdb->get_results($sql);\n\n if (!empty($results) && $results[0]->{'COUNT(*)'} > 0) {\n $submit_errors[]['email-1'] = __( 'The email provided already exists.' );\n return $submit_errors;\n }\n}, 10, 3 );<\/code><\/pre>\n\n\n\n