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
This commit is contained in:
Dwindi Ramadhana
2025-12-31 22:06:57 +07:00
parent 0dd7c7af70
commit f79938c5be

View File

@@ -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
}
}
}