Remove Entry Based on Value [RESOLVED]

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'] );
        }
    }
;}

Try this:

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'] );
    }
}
2 Likes

This works perfectly. Thank you @richardw8k!

1 Like