# One Gravity Forms Entry per Logged-In User

> Lets each logged-in member submit a Gravity Forms form only once, for surveys, applications or votes, and shows a friendly message instead of the form afterwards.

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

## Code

```php
$wpide_gf_once_forms   = array(); // Form IDs, e.g. array( 1 ).
$wpide_gf_once_message = 'You have already submitted this form. Thank you!';

$wpide_gf_user_has_entry = function ( $form_id ) {
    $user = get_current_user_id();

    return $user && GFAPI::count_entries( (int) $form_id, array( 'status' => 'active', 'field_filters' => array( array( 'key' => 'created_by', 'value' => $user ) ) ) ) > 0;
};

add_filter( 'gform_get_form_filter', function ( $html, $form ) use ( $wpide_gf_once_forms, $wpide_gf_once_message, $wpide_gf_user_has_entry ) {
    if ( in_array( (int) $form['id'], array_map( 'intval', $wpide_gf_once_forms ), true ) && $wpide_gf_user_has_entry( $form['id'] ) ) {
        return '<p class="wpide-gf-once" role="status">' . esc_html( $wpide_gf_once_message ) . '</p>';
    }

    return $html;
}, 10, 2 );

add_filter( 'gform_validation', function ( $validation ) use ( $wpide_gf_once_forms, $wpide_gf_once_message, $wpide_gf_user_has_entry ) {
    $form = $validation['form'];

    if ( in_array( (int) $form['id'], array_map( 'intval', $wpide_gf_once_forms ), true ) && $wpide_gf_user_has_entry( $form['id'] ) ) {
        $validation['is_valid'] = false;
        foreach ( $form['fields'] as $field ) {
            if ( ! in_array( $field->type, array( 'hidden', 'html', 'section', 'page' ), true ) ) {
                $field->failed_validation  = true;
                $field->validation_message = $wpide_gf_once_message;
                break;
            }
        }
        $validation['form'] = $form;
    }

    return $validation;
} );
```

## Notes

List the form IDs at the top and turn on "Require user to be logged in" in those forms' settings.

## How to use it

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