wc_delete_user_data()WC 1.0

When a user is deleted in WordPress, delete corresponding WooCommerce data.

Хуков нет.

Возвращает

null. Ничего (null).

Использование

wc_delete_user_data( $user_id );
$user_id(int) (обязательный)
User ID being deleted.

Код wc_delete_user_data() WC 9.4.2

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();
	}
}