Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_action( 'gform_after_submission', 'au_gfapi_delete_entry_gform_after_submission' );
- /**
- * Prevents Gravity Form to keep in the database stored entries
- * for a specific forms. In this example for forms with ID 2 and 3
- *
- * @param array $lead Array of lead data from submitted form.
- */
- function au_gfapi_delete_entry_gform_after_submission( $lead ) {
- // Define GravityForms form ID's for which we don't need saved entries
- $forms_to_skip = array(2, 3);
- // Check do we have matching form ID
- if ( in_array($lead['form_id'], $forms_to_skip) ) {
- // Check do we have class GFAPI (just in case)
- if ( class_exists('GFAPI') ) {
- // Delete entry - proper safe approach w/o manual messing with DB
- $ret = GFAPI::delete_entry( $lead['id'] );
- // Maybe we wish to do some error reporting on success?
- if ( WP_DEBUG && $ret === true ) {
- error_log("Entry #{$lead['id']} for form {$lead['form_id']} has been deleted!");
- }
- // Free some memory
- unset($ret);
- } // END if ( class_exists('GFAPI') )
- } // END if ( in_array($lead['form_id'], $forms_to_skip) )
- } // END function au_gfapi_delete_entry_gform_after_submission( $lead )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement