Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csalzano/efddaa69743753ee9e097fc471eaa35f to your computer and use it in GitHub Desktop.
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.
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