wc_reset_order_customer_id_on_deleted_user

Reset _customer_user on orders when a user is deleted.

Description

wc_reset_order_customer_id_on_deleted_user( (int) $user_id ); 

Parameters (1)

0. $user_id (int)
The user id.

Usage

  1. if ( !function_exists( 'wc_reset_order_customer_id_on_deleted_user' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-user-functions.php'; 
  3.  
  4. // The user id. 
  5. $user_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_reset_order_customer_id_on_deleted_user($user_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-user-functions.php  
  1. function wc_reset_order_customer_id_on_deleted_user( $user_id ) { 
  2. global $wpdb; 
  3.  
  4. $wpdb->update( $wpdb->postmeta, array( 'meta_value' => 0 ), array( 'meta_key' => '_customer_user', 'meta_value' => $user_id ) );