# Remove Entry Based on Value \[RESOLVED\]

**URL:** <https://community.gravityforms.com/t/remove-entry-based-on-value-resolved/3892>\
**Category:** Get Help\
**Tags:** custom, gfapi, delete\_entry\
**Created:** [February 12, 2020, 4:24pm UTC](https://community.gravityforms.com/t/remove-entry-based-on-value-resolved/3892 "2020-02-12T16:24:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gogrw](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/gogrw/32/1375_2.png) [@gogrw](https://community.gravityforms.com/u/gogrw)\
**Post date:** [February 12, 2020, 4:24pm UTC](https://community.gravityforms.com/t/remove-entry-based-on-value-resolved/3892/1 "2020-02-12T16:24:41Z")

</div>

I’m a little new to php, so bare with me. I’m trying to automatically remove entries based on a field’s value. I can swarmed with entries every day, but only want to keep the ones that meet certain criteria. I know that I can remove entries based on form id:

```
add_action( 'gform_after_submission_55, 'remove_form_entry' );
function remove_form_entry( $entry ) {GFAPI::delete_entry( $entry['id'] );}

```

But I’m having trouble getting it to work if field 1 equals “Standard Evaluation.” Here’s what I have so far. Any help is greatly appreciated.

```
add_action( 'gform_after_submission_55', 'remove_form_entry' );
function remove_form_entry( $entry ) {
    foreach ($entry as $ent){
        $entry = GFFormsModel::get_entry( $ent );
        if ( $field->id != 1 || $ent['value'] == 'Standard Evaluation' ){
            GFAPI::delete_entry( $entry['id'] );
        }
    }
;}
```

---

<div class="post-metadata">

**Author:** ![richardw8k](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/richardw8k/32/2354_2.png) [@richardw8k](https://community.gravityforms.com/u/richardw8k)\
**Post date:** [February 13, 2020, 4:53pm UTC](https://community.gravityforms.com/t/remove-entry-based-on-value-resolved/3892/2 "2020-02-13T16:53:33Z")

</div>

Try this:

```auto
add_action( 'gform_after_submission_55', 'remove_form_entry' );
function remove_form_entry( $entry ) {
    if ( rgar( $entry, '1' ) === 'Standard Evaluation' ) {
	    GFAPI::delete_entry( $entry['id'] );
    }
}

```

---

<div class="post-metadata">

**Author:** ![gogrw](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/gogrw/32/1375_2.png) [@gogrw](https://community.gravityforms.com/u/gogrw)\
**Post date:** [February 13, 2020, 8:57pm UTC](https://community.gravityforms.com/t/remove-entry-based-on-value-resolved/3892/3 "2020-02-13T20:57:45Z")

</div>

This works perfectly. Thank you @richardw8k!

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [February 13, 2020, 10:17pm UTC](https://community.gravityforms.com/t/remove-entry-based-on-value-resolved/3892/4 "2020-02-13T22:17:42Z")

</div>


