From a283351ef839c3c9ce66f43e33a7e4a105a0d9b8 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Thu, 27 Apr 2017 13:48:45 +0100 Subject: [PATCH] On multisite, add user to blog during checkout if not a user Fixes #14736 --- includes/class-wc-checkout.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/class-wc-checkout.php b/includes/class-wc-checkout.php index 59ac565c829..e134564ed1b 100644 --- a/includes/class-wc-checkout.php +++ b/includes/class-wc-checkout.php @@ -840,6 +840,11 @@ class WC_Checkout { WC()->cart->calculate_totals(); } + // On multisite, ensure user exists on current site, if not add them before allowing login. + if ( $customer_id && is_multisite() && is_user_logged_in() && ! is_user_member_of_blog() ) { + add_user_to_blog( get_current_blog_id(), $customer_id, 'customer' ); + } + // Add customer info from other fields. if ( $customer_id && apply_filters( 'woocommerce_checkout_update_customer_data', true, $this ) ) { $customer = new WC_Customer( $customer_id );