Description
The wpforms_process_before
action that fires after a form’s submit button is clicked, but before form data is validated or cleaned.
Parameters
- $entry
- (array) Unvalidated entry data.
- $form_data
- (array) Processed form settings/data, prepared to be used later.
Source
wpforms/includes/class-process.php
More Information
The action fires almost immediately after the form’s submit button is clicked, before validation takes place for the entry. Since entry data has not been validated or cleaned at this point in pre-processing, this hook should be used with caution.
The snippets below show more details about the parameters included in this hook (which each include an additional filter option).
$entry = apply_filters( 'wpforms_process_before_filter', $entry, $form_data ); $form_data = apply_filters( 'wpforms_process_before_form_data', wpforms_decode( $form->post_content ), $entry );
Perhaps you want to store all the form entries in a CRM and tag them as ‘failed’ until they fully process. Then using one of the later hooks, you could remove that ‘failed’ tag and update it with ‘completed’.
Just remember this hook is used prior to the data being validated so use this hook with caution.
Examples
Just remember to change the form ID from 5
to match the specific form ID you’re wanting to run your code on. Or remove it all together if you want to run this on all of your WPForms.
/** * This action fires almost immediately after the form’s submit button is clicked, before validation takes place for the entry. * * @link https://wpforms.com/developers/wpforms_process_before/ * * @param array $entry Unvalidated entry data. * @param array $form_data Form data and settings. */ function wpf_dev_process_before( $entry, $form_data ) { // Only run on my form with ID = 5 if ( absint( $form_data[ 'id' ] ) !== 5 ) { return; } // place your custom code here } add_action( 'wpforms_process_before', 'wpf_dev_process_before', 10, 2 );