• Resolved intolap

    (@intolap)


    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/

    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( '[email protected]', '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 to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Saurabh – WPMU DEV Support

    (@wpmudev-support7)

    Hi @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:

    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):

    <?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( '[email protected]', 'test forminator - '.$form_id, json_encode($form_data_array).json_encode($entry) );
    
    }

    Hope this information helps.

    Kind regards

    Luis

    Thread Starter intolap

    (@intolap)

    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

    (@intolap)

    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

    (@intolap)

    Does forminator have any option to add custom settings fields to every form programmatically?

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @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

    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

    (@wpmudevsupport12)

    Hi @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.