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:
@@ -313,6 +313,10 @@ class CheckoutController {
|
|||||||
|
|
||||||
// Send new account email (WooCommerce will handle this automatically via hook)
|
// Send new account email (WooCommerce will handle this automatically via hook)
|
||||||
do_action('woocommerce_created_customer', $new_user_id, $userdata, $password);
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user