Description

The wpforms_process_entry_save action fires when an entry is saved to the database.

Parameters

$fields
(array) Sanitized entry field values/properties.
$entry
(array) Original $_POST global.
$form_id
(int) Form ID.
$form_data
(array) Processed form settings/data, prepared to be used later.

Source

wpforms/includes/class-process.php

More Information

The action fires after the entry have been successfully processed when the entry is saved to the database. The confirmation event and notification email are triggered after this hook has run.

Below is the context in which the wpforms_process_entry_save hook is run.

This hook is also used in wpforms/pro/wpforms-pro.php, which loads features and functionality specific to the paid plugin version.

/**
 * @param  array $fields
 * @param  array $entry
 * @param  int   $form_id
 * @param  array $form_data
 *
 * @return int
 */

public function entry_save( $fields, $entry, $form_id, $form_data = '' ) {

	do_action( 'wpforms_process_entry_save', $fields, $entry, $form_id, $form_data );

	return $this->entry_id;
}

Examples

You could easily use this action to trigger something when the entries are saved to the database.

Just remember to change the form ID from 5 to match the specific form ID you want to run your code on. Removing that check would run for all forms.

/**
 * Action that fires when an entry is saved to the database.
 *
 * @link  https://wpforms.com/developers/wpforms_process_entry_save/
 *
 * @param array  $fields    Sanitized entry field. values/properties.
 * @param array  $entry     Original $_POST global.
 * @param int    $form_id   Form ID. 
 * @param array  $form_data Form data and settings.
 */

function wpf_dev_process_entry_save( $fields, $entry, $form_id, $form_data ) {
 
    // Only run on my form with ID = 5
    if ( absint( $form_data[ 'id' ] ) !== 5 ) {
            return $fields;
        } 
 
    // Example checking for the Yes value of a checkbox field (ID 6) and if yes, we'll then run our code
    if($fields[6][ 'value' ] === 'Yes') {
		
	// run some code here

	}
}
add_action( 'wpforms_process_entry_save', 'wpf_dev_process_entry_save', 10, 4 );

If you need any help on where to find your form and field IDs, please review this tutorial.

Reference Articles

How to Overwrite Entries From Users Who Have Already Submitted a Form