Advertisement
chrishajer

Delete entry immediately after it is saved

Feb 25th, 2013
2,318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.33 KB | None | 0 0
  1. <?php
  2. // originally http://pastie.org/1435911
  3. // http://www.gravityhelp.com/forums/topic/purposefully-not-save-form-in-entries-database#post-15601
  4. // change the 1 here to your form ID
  5. add_action('gform_after_submission_1', 'remove_form_entry', 10, 2);
  6. function remove_form_entry($entry, $form){
  7.     global $wpdb;
  8.  
  9.     $lead_id = $entry['id'];
  10.     $lead_table = RGFormsModel::get_lead_table_name();
  11.     $lead_notes_table = RGFormsModel::get_lead_notes_table_name();
  12.     $lead_detail_table = RGFormsModel::get_lead_details_table_name();
  13.     $lead_detail_long_table = RGFormsModel::get_lead_details_long_table_name();
  14.  
  15.     //Delete from detail long
  16.     $sql = $wpdb->prepare(" DELETE FROM $lead_detail_long_table
  17.                            WHERE lead_detail_id IN(
  18.                                SELECT id FROM $lead_detail_table WHERE lead_id=%d
  19.                            )", $lead_id);
  20.     $wpdb->query($sql);
  21.  
  22.     //Delete from lead details
  23.     $sql = $wpdb->prepare("DELETE FROM $lead_detail_table WHERE lead_id=%d", $lead_id);
  24.     $wpdb->query($sql);
  25.  
  26.     //Delete from lead notes
  27.     $sql = $wpdb->prepare("DELETE FROM $lead_notes_table WHERE lead_id=%d", $lead_id);
  28.     $wpdb->query($sql);
  29.  
  30.     //Delete from lead
  31.     $sql = $wpdb->prepare("DELETE FROM $lead_table WHERE id=%d", $lead_id);
  32.     $wpdb->query($sql);
  33.  
  34. }
  35.  
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement