Description

The wpforms_frontend_form_action filter is used to alter the default form action on submission of the form.

Parameters

$action
(array) Action to be taken on form submit.
$form_data
(array) Processed form settings/data, prepared to be used later.

Source

wpforms/src/Frontend/Frontend.php

More Information

The filter can be used to alter the default action of the form.

Example

In this example for form ID 999, we’re modifying the form action URL. Remember to update the form ID to match your form ID.

/**
 * Alter default action of form submission.
 *
 * @link    https://wpforms.com/developers/wpforms_frontend_form_action/
 *
 * @param   array  $action     Returning action to be taken on form submit.
 * @param   array  $form_data  Form data.
 *
 * @return  array
 */

function wpf_custom_form_action( $action, $form_data ) {

// Check if the form ID matches the form where you want to modify the action.
    if ( $form_id === 999 ) { // Replace 999 with your form ID.

        // Modify the form action URL as needed.
        $form_action = 'https://example.com/custom-action';
    }
    return $form_action;
}

add_filter( 'wpforms_frontend_form_action', 'wpf_custom_form_action', 10, 2 );

Please note, if you are going to use this filter for redirect, your entry will not be saved into the WPForms entries and AJAX will need to be disabled in order for the redirect to take place.

Reference Articles

How to Customize the Form Action