Don't Keep Entries for Certain Gravity Forms Forms
Deletes the entry of the forms you list right after its notifications are sent, so sensitive submissions live only in your inbox and never in the database.
Opens WPIDE on
Code
$wpide_gf_no_storage_forms = array(); // Form IDs whose entries should not be kept, e.g. array( 3 ).
add_action( 'gform_after_submission', function ( $entry, $form ) use ( $wpide_gf_no_storage_forms ) {
if ( in_array( (int) $form['id'], array_map( 'intval', $wpide_gf_no_storage_forms ), true ) && ! empty( $entry['id'] ) ) {
GFAPI::delete_entry( (int) $entry['id'] );
}
}, 999, 2 );
Notes
Runs after notifications and add-on feeds that process on submission; delayed feeds such as payment add-ons would lose their entry, so only list simple contact forms.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.