wc_delete_user_data( int $user_id )
When a user is deleted in WordPress, delete corresponding WooCommerce data.
Description Description
Parameters Parameters
- $user_id
-
(Required) User ID being deleted.
Source Source
File: includes/wc-user-functions.php
function wc_delete_user_data( $user_id ) { global $wpdb; // Clean up sessions. $wpdb->delete( $wpdb->prefix . 'woocommerce_sessions', array( 'session_key' => $user_id, ) ); // Revoke API keys. $wpdb->delete( $wpdb->prefix . 'woocommerce_api_keys', array( 'user_id' => $user_id, ) ); // Clean up payment tokens. $payment_tokens = WC_Payment_Tokens::get_customer_tokens( $user_id ); foreach ( $payment_tokens as $payment_token ) { $payment_token->delete(); } }