By default, Gravity Forms was designed to record all data submitted to it, so there isn』t an override to stop Gravity Forms from storing entry data upon submission. The reason for this is the entry must be saved so the data is available when notifications are sent and feed based add-ons, like PayPal and User Registration, are processed.
That said, Gravity Forms 2.4 did introduce Personal Data Settings which include the ablity to enable automatic deletion of entries after a specified number of days.
Bear in mind when entries are deleted, files associated with the entry are also deleted. If you want to keep the files, use the gform_field_types_delete_files filter.
There are also a number of third-party add-ons which can be used to delete entries either as the form submission ends or at a scheduled date/time:
Gravity Flow
Entry Automation by ForGravity
Gravity Perks – Disable Entry Creation by Gravity Wiz
Gravity Forms Encrypted Fields by PluginOwl
Gravity Forms Utility by Gravity+
Wider Gravity Forms Stop Entries by Jonny Allbut
If you would prefer not to use one of the above solutions you can use custom code in the theme functions.php file or a custom functionality plugin that will wait until the data is recorded, and then go in and remove the entry that was just created. To do so, you would use the following code which works with Gravity Forms 1.8 and newer:
123456// 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 is applicable to Gravity Forms 1.7 and earlier only.
123456789101112131415161718192021222324252627282930add_action('gform_after_submission_1', 'remove_form_entry', 10, 2);function remove_form_entry($entry, $form){ global $wpdb; $lead_id = $entry['id']; $lead_table = RGFormsModel::get_lead_table_name(); $lead_notes_table = RGFormsModel::get_lead_notes_table_name(); $lead_detail_table = RGFormsModel::get_lead_details_table_name(); $lead_detail_long_table = RGFormsModel::get_lead_details_long_table_name(); //Delete from detail long $sql = $wpdb->prepare(" DELETE FROM $lead_detail_long_table WHERE lead_detail_id IN( SELECT id FROM $lead_detail_table WHERE lead_id=%d )", $lead_id); $wpdb->query($sql); //Delete from lead details $sql = $wpdb->prepare("DELETE FROM $lead_detail_table WHERE lead_id=%d", $lead_id); $wpdb->query($sql); //Delete from lead notes $sql = $wpdb->prepare("DELETE FROM $lead_notes_table WHERE lead_id=%d", $lead_id); $wpdb->query($sql); //Delete from lead $sql = $wpdb->prepare("DELETE FROM $lead_table WHERE id=%d", $lead_id); $wpdb->query($sql); }
The expected behavior would be that the entry would not exist in the Gravity Forms database tables after submission. If you are having issues with this script, please read up on our gform_after_submission hook.