Skip to content

Instantly share code, notes, and snippets.

@richardW8k
richardW8k / RW_Delete_Entry.php
Last active January 20, 2022 07:21
When placed in the theme functions.php file this will add a checkbox to the 'Form Options' part of the Form Settings page which when checked will cause entries to be automatically deleted at the end of the submission process.
<?php
class RW_Delete_Entry {
function __construct() {
if( ! property_exists( 'GFCommon', 'version' ) || ! version_compare( GFCommon::$version, '1.8.5.8', '>=' ) )
return;
add_filter( 'gform_tooltips', array( $this, 'add_delete_tooltip') );
add_filter( 'gform_form_settings', array( $this, 'add_delete_setting' ), 10, 2 );
add_action( 'gform_pre_form_settings_save', array( $this, 'save_delete_setting' ), 10 );
add_action( 'gform_after_submission', array( $this, 'maybe_delete_form_entry' ), 15, 2 );