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

Related Articles

2 comments on “How to delete Gravity Form entries on submission

    1. 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.

Leave a Reply

Your email address will not be published.