Overview
By default, Gravity Forms is designed to record all submitted data. Entries must be saved so notifications can be sent and feed-based add-ons, such as PayPal or User Registration, can process correctly. For this reason, there is no built-in setting to prevent entry creation at the moment of submission.
Automatic Deletion (Recommended)
Gravity Forms 2.4 and newer include Personal Data Settings, which provide the ability to delete entries after a specified number of days automatically.
This is the recommended solution for most sites that need automated cleanup or short-term retention.
When an entry is deleted, any associated file uploads are also removed. To retain files while still deleting entries, use the gform_field_types_delete_files filter.
Third-Party Solutions
Several third-party add-ons support deleting entries immediately upon submission or on a scheduled basis:
- Gravity Flow Form Connector Extension
- Disable Entry Creation Perk by Gravity Wiz
- Entry Automation by CosmicGiant
- Gravity Forms Encrypted Fields by PluginOwl
Custom Code Option
If you prefer not to use one of the above solutions, you can use custom code in the theme’s functions.php file or a custom functionality plugin that waits until the data is recorded, and then removes the entry that was just created. To do so, you would use the following code, which works with Gravity Forms 1.8 and newer:
// Target submissions from form ID 1.
// Change gform_after_submission_1 to reflect your target form ID, or use gform_after_submission to target all forms.
add_action( 'gform_after_submission_1', 'remove_form_entry' );
function remove_form_entry( $entry ) {
GFAPI::delete_entry( $entry['id'] );
}
The following code applies to Gravity Forms 1.7 and earlier only.
// Target submissions from form ID 1.
// Change gform_after_submission_1 to reflect your target form ID, or use gform_after_submission to target all forms.
add_action( 'gform_after_submission_1', 'remove_form_entry' );
function remove_form_entry( $entry ) {
GFAPI::delete_entry( $entry['id'] );
}
The expected behavior would be that the entry would not exist in the Gravity Forms database tables after submission. If you are experiencing issues with this script, please refer to our gform_after_submission hook.
Placement
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?
Disclaimer: Third-party services, plugins, or code snippets that are referenced by our Support documentation or in Support Team communications are provided as suggestions only. We do not evaluate, test or officially support third-party solutions. You are wholly responsible for determining if any suggestion given is sufficient to meet the functional, security, legal, ongoing cost and support needs of your project.
Feedback, feature and integration requests, and other functionality ideas can be submitted on our Gravity Forms, Gravity Flow, or Gravity SMTP product roadmap pages.