Created
June 22, 2015 14:51
-
-
Save muhammad-naderi/1c3049a9e8f5e1ca3633 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$sign_in_form_id = 6; | |
add_action( 'gform_after_submission_' . $sign_in_form_id , 'mu_remove_form_entry' ); | |
/** | |
* Prevents Gravity Form entries from being stored in the database | |
* for a specific form. with $sign_in_form_id Id. | |
* | |
* @global object $wpdb The WP database object. | |
* @param array $entry Array of entry data. | |
*/ | |
function mu_remove_form_entry( $entry ) { | |
global $wpdb; | |
// Prepare variables. | |
$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 lead 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 ); | |
// Finally, ensure everything is deleted (like stuff from Addons). | |
GFAPI::delete_entry( $lead_id ); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment