Title: An error occurred while processing the form
Last modified: July 9, 2023

---

# An error occurred while processing the form

 *  Resolved [intolap](https://wordpress.org/support/users/intolap/)
 * (@intolap)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/an-error-occurred-while-processing-the-form-3/)
 * Hi there
   I have an issue while submitting forms in Forminator. An error occurred
   while processing the form. Please try clicking the WhatsApp button on [https://webdemo.intolap.com/wp/](https://webdemo.intolap.com/wp/)
   It will open a popup with a forminator form. When you submit it you will see 
   an “error statement”Well I am trying to process the form data on submit using
   your hooks like`add_action( 'forminator_custom_form_submit_before_set_fields','
   woow_forminator_beofre_set_handler' );public function woow_forminator_beofre_set_handler(
   $entry, $form_id, $form_data_array ){// echo "<pre>"; print_r($response);wp_mail('
   intolap@gmail.com', 'test forminator - '.$form_id, json_encode($form_data_array).
   json_encode($entry) );}
 * forminator_form_ajax_submit_response
   When I remove this function from my codes,
   the form submits but with the hooks on, it doesn’t.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fan-error-occurred-while-processing-the-form-3%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Support [Saurabh – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support7/)
 * (@wpmudev-support7)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/an-error-occurred-while-processing-the-form-3/#post-16881945)
 * Hi [@intolap](https://wordpress.org/support/users/intolap/)
 * Hope you are doing fine.
 * I performed a test on my lab site using the same code. A critical error was displayed
   on my end as well and found this in the logs:
 *     ```wp-block-code
       PHP Parse error: syntax error, unexpected token "public", expecting end of file in /var/web/site/public_html/wp-content/mu-plugins/mu-plugin-test.php on line 4
       ```
   
 * Basically, it means the “public” keyword should not be used in the code, since
   the function is not added inside a class. You can modify the code and change 
   it to this (removed the “public” word from the code):
 *     ```wp-block-code
       <?php 
   
       add_action( 'forminator_custom_form_submit_before_set_fields', 'woow_forminator_beofre_set_handler');
   
       function woow_forminator_beofre_set_handler( $entry, $form_id, $form_data_array ){
   
       wp_mail( 'intolap@gmail.com', 'test forminator - '.$form_id, json_encode($form_data_array).json_encode($entry) );
   
       }
       ```
   
 * Hope this information helps.
 * Kind regards
 * Luis
 *  Thread Starter [intolap](https://wordpress.org/support/users/intolap/)
 * (@intolap)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/an-error-occurred-while-processing-the-form-3/#post-16882181)
 * Hi Luis,
   You picked it right about the public keyword. Well, actually I am using
   this function inside a class. But just to post it here I extracted the code and
   forgot to remove the public keyword.Did you check my lines of code without public
   keyword?
 *  Thread Starter [intolap](https://wordpress.org/support/users/intolap/)
 * (@intolap)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/an-error-occurred-while-processing-the-form-3/#post-16882241)
 * Thanks, now it works. I found the solution in the log.
   add_action( ‘forminator_custom_form_submit_before_set_fields’,‘
   woow_forminator_beofre_set_handler’,** 10, 3**);What was missing is the priority
   and the number of arguments.
 *  Thread Starter [intolap](https://wordpress.org/support/users/intolap/)
 * (@intolap)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/an-error-occurred-while-processing-the-form-3/#post-16882538)
 * Does forminator have any option to add custom settings fields to every form programmatically?
 *  Plugin Support [Laura – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support8/)
 * (@wpmudev-support8)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/an-error-occurred-while-processing-the-form-3/#post-16886157)
 * Hi [@intolap](https://wordpress.org/support/users/intolap/)
 * Forminator does have option to add fields to forms via code, see here, please:
 * [https://wpmudev.com/docs/api-plugin-development/forminator-api-docs/#method-add_form_field](https://wpmudev.com/docs/api-plugin-development/forminator-api-docs/#method-add_form_field)
 * However, the “add_form_field” method is for adding actual field. I’m not quite
   sure what do you mean by “custom settings fields” specifically so I’m not sure
   if it will be suitable in this case.
 * Would you mind explaining a bit more what do you mean exactly by “custom settings
   field”?
 * Kind regards,
    Adam
 *  Plugin Support [Patrick – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport12/)
 * (@wpmudevsupport12)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/an-error-occurred-while-processing-the-form-3/#post-16914053)
 * Hi [@intolap](https://wordpress.org/support/users/intolap/)
 * I hope you are doing well and safe!
 * We haven’t heard from you in a while, I’ll mark this thread as resolved.
 * Feel free to let us know if you have any additional questions or problems.
 * Best Regards
    Patrick Freitas

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘An error occurred while processing the form’ is closed to new replies.

 * ![](https://ps.w.org/forminator/assets/icon-256x256.gif?rev=3443182)
 * [Forminator Forms – Contact Form, Payment Form & Custom Form Builder](https://wordpress.org/plugins/forminator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/forminator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/forminator/)
 * [Active Topics](https://wordpress.org/support/plugin/forminator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/forminator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/forminator/reviews/)

 * 6 replies
 * 4 participants
 * Last reply from: [Patrick – WPMU DEV Support](https://wordpress.org/support/users/wpmudevsupport12/)
 * Last activity: [2 years, 10 months ago](https://wordpress.org/support/topic/an-error-occurred-while-processing-the-form-3/#post-16914053)
 * Status: resolved