How to delete Gravity Form entries on submission

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 form that emails the submissions or saves the submission data to another database.

You can use the code by adding it to your theme’s functions.php file (anywhere after the opening <?php line).

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