Need to stop Multiple Form Submission with Same Field Datas
-
Hi, I’m facing duplicate entries currently, I enabled inline validation but received duplicate multiple entries with the same field data, can you please tell me how can I stop that.
Thanks,
JaganThe page I need help with: [log in to see the link]
-
Hi @ejaganece
I hope you are doing well today.
Could you export your form, upload it to google drive or dropbox and share a link in your next reply?
We would like to test import of that form on our lab site.
Kind Regards,
KrisThanks for the reply, please use this link https://www.dropbox.com/s/huv3khvmjj84xoj/forminator-members-form-export%20-feb01-2023.txt?dl=0
Thanks,
JaganHi @ejaganece
Thank you for sharing the form!
I checked it and the form itself seems fine – there’s nothing wrong with its settings and configuration and appears to be working fine on my end.
What you may try would be to enable “Prevent page caching on form pages” and/or “Load form using AJAX” options in form’s “Behavior” settings as those would help mitigate any duplication issues possibly related to some kind of caching on site or server.
But if that doesn’t help, let me ask additionally:
– are you seeing those multiplied submissions on “Form -> Submissions” page or is it only that you’re getting multiple e-mail notifications about same submissions?
– if it’s the first case – are you absolutely sure that those are multiplied single submissions and not just form submitted multiple times (by user or some bot) with just the same data?
Kind regards,
AdamThanks for the reply, currently i’m using mobile number field in my form and receiving multiple forms with same mobile number, so i need to restrict that with single form per mobile number.
Thanks,
JaganHi @ejaganece,
I hope you are doing well today!
You can use the following code snippet as mu-plugin, just make sure to change “email-1” on line 17 with the name of the field you want to restrict.
https://gist.github.com/wpmudev-sls/0e27c6cc39e114038eba04a03e4aed40
You can find more information below on how to use mu-plugins.
https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-pluginsMust Use Plugins
Kind regards,
ZaferSorry for late reply, form submit result showing “An error occurred processing the form. Please try again.” when i added those codes in snippet.
Thanks,
JaganHi @ejaganece
I checked the shared code and it seems that we didn’t notice that it’s actually already a bit old. It’s a custom code and not any official “add-on” (even though made by us) and such codes are not updated often. In this case it seems that due to the changes in the plugin since the code was created, it is no longer correctly working.
I sincerely apologize for our mistake.
That being said, I gave it a shot and came up with a bit simpler code. Please remove the one we’ve shared earlier and instead add this one the same way:
<?php add_filter( 'forminator_custom_form_submit_errors', 'check_form_duplicate_submission_data', 99, 3 ); function check_form_duplicate_submission_data( $submit_errors, $form_id, $field_data_array ) { $form_ids = array( 2245, 123 ); // form IDs - one or more; if more - separate numbers with commas $fields_ids = array( 'phone-1' ); // IDs of fields to check, one or more, if more - separate with commas if ( !in_array( $form_id, $form_ids ) ) { return $submit_errors; // just bail out and skip checks } foreach( $field_data_array as $key => $value ) { $field_name = $value['name']; if ( in_array( $field_name, $fields_ids ) ) { $entries = Forminator_Form_Entry_Model::select_count_entries_by_meta_field( $form_id, $field_name, $value['value'], '*' ); if ( $entries ) { $submit_errors[][$field_name] = 'Duplicated entry'; } } } return $submit_errors; }
Note that you’ll need to configure form IDs (form ID is the same number you can see in form shortocode) and IDs of fields to be checked in these lines:
$form_ids = array( 2245, 123 ); // form IDs - one or more; if more - separate numbers with commas $fields_ids = array( 'phone-1' ); // IDs of fields to check, one or more, if more - separate with commas
Here you can also configure custom error message:
$submit_errors[][$field_name] = 'Duplicated entry';
Best regards,
AdamThanks a lot, it’s working fine.
Thanks,
Jagan
- The topic ‘Need to stop Multiple Form Submission with Same Field Datas’ is closed to new replies.