# One Gravity Forms Entry per Email Address per Day

> Prevents the same email address from submitting a Gravity Forms form more than once in 24 hours, useful for giveaways, sign-ups and quote forms.

- Type: PHP
- Runs: Run everywhere
- Category: [Forms](https://wpide.com/library/category/forms/)
- Tags: gravity-forms, validation, duplicates
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/gf-one-entry-per-email/

## Code

```php
$wpide_gf_daily_forms = array(); // Form IDs to protect, e.g. array( 1 ).
$wpide_gf_daily_hours = 24;

add_filter( 'gform_field_validation', function ( $result, $value, $form, $field ) use ( $wpide_gf_daily_forms, $wpide_gf_daily_hours ) {
    if ( 'email' !== $field->type || ! $result['is_valid'] || ! in_array( (int) $form['id'], array_map( 'intval', $wpide_gf_daily_forms ), true ) ) {
        return $result;
    }

    $email = strtolower( trim( is_array( $value ) ? (string) reset( $value ) : (string) $value ) );
    if ( ! is_email( $email ) ) {
        return $result;
    }

    $count = GFAPI::count_entries( (int) $form['id'], array(
        'status'        => 'active',
        'start_date'    => wp_date( 'Y-m-d H:i:s', time() - $wpide_gf_daily_hours * HOUR_IN_SECONDS ),
        'field_filters' => array( array( 'key' => (string) $field->id, 'value' => $email ) ),
    ) );

    if ( $count > 0 ) {
        $result['is_valid'] = false;
        $result['message']  = 'This email address has already been used today.';
    }

    return $result;
}, 10, 4 );
```

## Notes

Only checks the forms listed at the top, using each form's first email field; Gravity Forms' own "No Duplicates" setting blocks repeats forever instead.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "One Gravity Forms Entry per Email Address per Day" 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/
