From f79938c5bed2cc252b754a907e015df5b6769173 Mon Sep 17 00:00:00 2001 From: Dwindi Ramadhana Date: Wed, 31 Dec 2025 22:06:57 +0700 Subject: [PATCH] feat: auto-login newly registered customers after checkout - After creating new user account, immediately log them in - Uses wp_set_current_user() and wp_set_auth_cookie() - Provides smoother UX - customer is logged in after placing order --- includes/Api/CheckoutController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/Api/CheckoutController.php b/includes/Api/CheckoutController.php index 8459001..9c1407c 100644 --- a/includes/Api/CheckoutController.php +++ b/includes/Api/CheckoutController.php @@ -313,6 +313,10 @@ class CheckoutController { // Send new account email (WooCommerce will handle this automatically via hook) do_action('woocommerce_created_customer', $new_user_id, $userdata, $password); + + // Auto-login the newly registered user for smoother UX + wp_set_current_user($new_user_id); + wp_set_auth_cookie($new_user_id, true); // true = remember me } } }