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'] ); } }
Does this code go in the functions.php of WordPress?
Yes, in the functions.php file in your active theme would do fine – I’ll add it to the instructions for others.
You can actually include code customisations in other places, personally I
put mine in a ‘custom’ plugin – that way when the theme upgrades I dont
loose my code customisations.