1. Home
  2. Actions
  3. Action reference: wpforms_process

do_action( 'wpforms_process', array $fields, array $entry, array $form_data )

Action that fires during form entry processing, after initial field validation has passed.


The wpforms_process action fires towards the end of form entry processing. It runs after all initial form fields have been validated and sanitized.

This hook should be used when the action potentially needs to return an error and halt form processing (see More Information below for details). Examples: verify if a user account exists or validate data for a payment gateway.

Please remember that the form processing can still be halted/prevented after this hooks fires, by other code using the same hook. See the note below about another similar hook that fires after all validation is passed.

Important note: If you are doing processing and do not need validation or need the entry ID, see wpforms_process_complete.


(array) Sanitized entry field values/properties.
(array) Original $_POST global.
(array) Form settings/data.



More Information

In order to halt the form submission and display an error, you’d need to use the snippet below (be sure to read comments for customizing tips):

add_action( 'wpforms_process', function ( $fields, $entry, $form_data ) {

    $value_to_check = true;

    if ( ! $value_to_check ) {
        // Add to global errors. This will stop form entry from being saved to the database.
        // Error id displayed above the form.
        wpforms()->process->errors[ $form_data['id'] ]['header'] = esc_html__( 'Some error occurred.', 'plugin-domain' );

        // Uncomment the line below if you need to display the error for a specific field. 
        // wpforms()->process->errors[ $form_data['id'] ][ $field_id ] = esc_html__( 'Some error occurred.', 'plugin-domain' );
        // Return early, so the code below won't fire.

    // Add additional logic (what to do if error is not displayed)
}, 10, 3 );
Updated on July 24, 2019

Was this article helpful?