• Resolved mor3311

    (@mor3311)


    Hi,
    I am trying to run a function after form submission, if the response is ‘success’.
    So I tried for example redirecting home just to check if the function is working – and it’s not.

    please help me?
    the code:

    add_action( 'forminator_form_after_handle_submit', 'save_fielder_details', 10, 2);
    function save_fielder_details($form_id, $response) {
        if( $response['success'] ){
            wp_safe_redirect( home_url() );
        }
    }
    
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Imran – WPMU DEV Support

    (@wpmudev-support9)

    Hello @mor3311 !

    I trust you’re doing well!

    We’ve recently made changes to the actions and filters in Forminator – forminator_form_after_handle_submit is no longer available because of this and instead you can use forminator_form_submit_response and/or forminator_form_ajax_submit_response and reverse the parameters.

    More on this here: https://wpmudev.com/docs/api-plugin-development/forminator-api-docs/#modified-or-deprecated-hooks

    Also – the hook you want to use here is a filter so it needs to return the $response further. You can test it instead of a redirect by enabling debugging log and logging the values like this:

    So your code would look like this after modifications

    add_action( 'forminator_form_submit_response', 'save_fielder_details', 10, 2);
    add_action( 'forminator_form_ajax_submit_response', 'save_fielder_details', 10, 2);
    function save_fielder_details($response, $form_id) {
    	error_log(print_r($response, true));
    
    	return $response;
    }

    You can then run some additional code by checking:

    if( $response['success'] == 1 ){
            // your code here
    }

    Hope this helps!

    Warm regards,
    Pawel

    Thread Starter mor3311

    (@mor3311)

    Hi, thanks for your response!
    I tried this solution but I get the following error:

    An error occurred while processing the form. Please try again
    (undefined)

    Thread Starter mor3311

    (@mor3311)

    I actually want to save some details of the form as user_meta.
    What is the right way to do this, and where should I place the code?

    Plugin Support Nebu John – WPMU DEV Support

    (@wpmudevsupport14)

    Hi @mor3311,

    Can you please share an export of the form and the complete code you have tried so we can try to help you with this?

    Please share the form’s export using Google Drive or DropBox. Please find how to export a form here: https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#import-export

    We look forward to hearing back from you.

    Kind Regards,
    Nebu John

    Thread Starter mor3311

    (@mor3311)

    Hi, sorry for the delay!
    I managed to save the data I wanted. ??
    Thanks for your answer!!

    Plugin Support Nebu John – WPMU DEV Support

    (@wpmudevsupport14)

    Hi @mor3311,

    Glad to know that you managed to save the data.

    Please feel free to open a new ticket if you need any other help.

    If you found our plugin helpful, wouldn’t you mind please leaving a rating for us?

    https://www.ads-software.com/support/plugin/forminator/reviews/

    Kind Regards,
    Nebu John

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘forminator_form_after_handle_submit not working’ is closed to new replies.