### [wpforms_process_filter](https://wpforms.com/developers/wpforms_process_filter/)

**Published:** April 22, 2020
**Author:** Editorial Team

**Excerpt:** The wpforms_process_filter fires after all field validation and formatting data.


**Content:**

## Description

The `wpforms_process_filter` fires after all field validation and formatting data.

## Parameters

$fields*(array)* Sanitized entry field values/properties.$entry*(array)* Original $\_POST global.$form\_data*(array)* Processed form settings/data, prepared to be used later.## Source

`wpforms/includes/class-process.php`

## More Information

The filter fires at the very end once the field validation and formatting the data.

## Examples

Remember to change your form ID from **817** to the form ID that you’re targeting.

This example will look to see if there is a Ratings field on this particular form and if the user doesn’t complete this field, it will default the rating to 0.

```

/**
 * Fires after all field validation and formatting data.
 *
 * @link  https://wpforms.com/developers/wpforms_process_filter/
 *
 * @param  array  $fields     Sanitized entry field values/properties.
 * @param  array  $entry      Original $_POST global.
 * @param  array  $form_data  Form data and settings.
 *
 * @return array 
 */

function wpf_dev_process_filter( $fields, $entry, $form_data ) {
	
	$form_id = 817; // Change form ID
	
	// Bail early if form ID does not match
	if ( $form_data[ 'id' ] != $form_id ) {
		return $fields;
	}
	
	foreach ( $fields as $field ) {
		
		// If field type is rating and it is empty, assign a value of 0
		if ( $field[ 'type' ] == 'rating' && empty( $field[ 'value' ] ) ) {
			
			$fields[$field[ 'id' ]][ 'value' ] = 0;
			
		}
		
	}
	
	return $fields;
     
}
add_filter( 'wpforms_process_filter', 'wpf_dev_process_filter', 10, 3 );
```

Another example could be when the [Show Values](https://wpforms.com/developers/add-field-values-for-dropdown-checkboxes-and-multiple-choice-fields/ "How to Add Field Values for Dropdown, Checkboxes, and Multiple Choice Fields") tutorial has been implemented to save the `value` instead of the label.

```

/**
 * Save choices `values` instead of `labels` for the fields with `Show values` option enabled.
 *
 * @link   https://wpforms.com/developers/wpforms_process_filter/
 *
 * @param  array  $fields    Sanitized entry field. values/properties.
 * @param  array  $entry     Original $_POST global.
 * @param  array  $form_data Form data and settings.
 */

function wpf_dev_process_filter_choices_values( $fields, $entry, $form_data ) {

	if ( ! is_array( $fields ) ) {
		return $fields;
	}

	foreach ( $fields as $field_id => $field ) {
		if (
			isset( $field[ 'type' ] ) &&
			in_array( $field[ 'type' ], [ 'checkbox', 'radio', 'select' ], true ) &&
			! empty( $form_data[ 'fields' ][ $field_id ][ 'show_values' ] )
		) {
			$value_raw = ! empty( $field[ 'value_raw' ] ) ? $field[ 'value_raw' ] : '';
			$field[ 'value_raw' ] = $field[ 'value' ];
			$field[ 'value' ] = $value_raw;
			$fields[ $field_id ] = $field;
		}
	}

	return $fields;
};
add_filter( 'wpforms_process_filter', 'wpf_dev_process_filter_choices_values', 10, 3 );

```

## Reference Articles

- [How to Increment a Count on Each Form Submission](https://wpforms.com/developers/how-to-increment-a-count-on-each-form-submission/ "How to Increment a Count on Each Form Submission")
- [How to Store the Non-Cached IP Address Into a Hidden Field](https://wpforms.com/developers/how-to-store-the-non-cached-ip-address-into-a-hidden-field/ "How to Store the Non-Cached IP Address Into a Hidden Field")

**Categories:** Filters Hooks

**Tags:** PHP

---

