Description

Action that fires when 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) Form settings/data.

Source

wpforms/includes/class-process.php

More Information

The wpforms_process_entry_save action fires after the entry has been successfully processed, when the entry is being saved to the database. Both 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 were saved to the database.

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

/**
 * Action that fires when 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 and if yes, we'll then run our code
    if($fields[6]['value'] === 'Yes') {
		
	// run code here

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