The following code will automatically delete Gravity Form entries after submission.
This may be helpful for test or demo forms, or forms that do not need to retain the entry data in the WordPress database – for example, a registration form, a form that emails the submissions or saves the submission data to another database.
If you’re not sure where to place this code I highly recommend you read How to create a WordPress plugin for your custom functions.
Delete entry after submission – all forms
This function will apply to all forms.
add_action( 'gform_after_submission', 'remove_form_entry' ); function remove_form_entry( $entry ) { GFAPI::delete_entry( $entry['id'] ); }
Delete entry after submission – specific forms
This function will only apply to form ID 1.
add_action( 'gform_after_submission', 'remove_form_entry' ); function remove_form_entry( $entry ) { if ( 1 == rgar( $entry, 'form_id' ) ) { GFAPI::delete_entry( $entry['id'] ); } }