# Tidy Up WPForms Submissions

> Trims spaces, lowercases email addresses and capitalizes all-lowercase names in WPForms submissions before they are emailed or stored.

- Type: PHP
- Runs: Run everywhere
- Category: [Forms](https://wpide.com/library/category/forms/)
- Tags: wpforms, data, cleanup
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/wpforms-normalize-data/

## Code

```php
add_filter( 'wpforms_process_filter', function ( $fields ) {
    foreach ( (array) $fields as $id => $field ) {
        if ( ! isset( $field['value'] ) || ! is_string( $field['value'] ) ) {
            continue;
        }

        $value = trim( $field['value'] );

        if ( 'email' === $field['type'] ) {
            $value = strtolower( $value );
        } elseif ( 'name' === $field['type'] && ( $value === strtolower( $value ) || $value === strtoupper( $value ) ) ) {
            $value = mb_convert_case( $value, MB_CASE_TITLE, 'UTF-8' );
        }

        $fields[ $id ]['value'] = $value;
    }

    return $fields;
} );
```

## Notes

Names typed in mixed case (such as McDonald) are left as they are.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Tidy Up WPForms Submissions" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
