Created
April 25, 2018 16:19
-
-
Save csalzano/efddaa69743753ee9e097fc471eaa35f to your computer and use it in GitHub Desktop.
Gravity Forms does not dissociate deleted users from form entries. This code removes user IDs from entries when users are deleted.
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
add_action( 'delete_user', 'remove_deleted_user_from_gform_entries' ); | |
function remove_deleted_user_from_gform_entries( $user_id ) { | |
//$user_id was just deleted, remove this from any entries if stored as created_by | |
global $wpdb; | |
$wpdb->query( $wpdb->prepare( " | |
UPDATE `{$wpdb->prefix}gf_entry` | |
SET `created_by` = NULL | |
WHERE `created_by` = %d | |
", $user_id ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment