Merge pull request #9290 from woothemes/issue/9166-reset-order-customer-id-on-user-delete
When a WordPress user is deleted, turn any orders they have into Guest orders.
This commit is contained in:
commit
5bc7de0d91
|
@ -537,3 +537,14 @@ function wc_get_customer_order_count( $user_id ) {
|
|||
|
||||
return absint( $count );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset _customer_user on orders when a user is deleted.
|
||||
* @param int $user_id
|
||||
*/
|
||||
function wc_reset_order_customer_id_on_deleted_user( $user_id ) {
|
||||
global $wpdb;
|
||||
|
||||
$wpdb->update( $wpdb->postmeta, array( '_customer_user' => 0 ), array( '_customer_user' => $user_id ) );
|
||||
}
|
||||
add_action( 'deleted_user', 'wc_reset_customer_id_on_delete_user' );
|
Loading…
Reference in New Issue