# Tidy Names and Emails in Gravity Forms Entries

> Trims spaces, lowercases email addresses and capitalizes names in Gravity Forms entries before they are saved, so your lists and CRM exports look consistent.

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

## Code

```php
add_filter( 'gform_save_field_value', function ( $value, $entry, $field, $form, $input_id ) {
    if ( ! is_string( $value ) || ! is_object( $field ) ) {
        return $value;
    }

    $value = trim( $value );

    if ( 'email' === $field->type ) {
        return strtolower( $value );
    }

    if ( 'name' === $field->type && ( $value === strtolower( $value ) || $value === strtoupper( $value ) ) ) {
        return function_exists( 'mb_convert_case' ) ? mb_convert_case( $value, MB_CASE_TITLE, 'UTF-8' ) : ucwords( strtolower( $value ) );
    }

    return $value;
}, 10, 5 );
```

## Notes

Names already in mixed case (such as McDonald) are left as typed; only all-lowercase or all-uppercase names are changed.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Tidy Names and Emails in Gravity Forms Entries" 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/
