Atenção!

Este artigo contém código PHP e destina-se a desenvolvedores. Oferecemos este código como uma cortesia, mas não fornecemos suporte para personalizações de código ou desenvolvimento de terceiros.

Para orientação extra, consulte o tutorial do WPBeginner sobre como adicionar código personalizado.

Dispensar

Descrição

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

Parâmetros

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

Fonte

wpforms/src/Frontend/Frontend.php

Mais Informações

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

Exemplo

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.

Artigos de Referência

Como Personalizar a Ação do Formulário