fix: use checkout domain for email verification URLs#961
Conversation
When a checkout form lives on a different domain than the main site, the verification email link now points back to that same domain instead of always using the main site URL. This ensures the customer's auth cookie (set during checkout) is valid when they click the verification link. - Add META_CHECKOUT_BLOG_ID constant and getter/setter to Customer model - Store the current blog ID on the customer during checkout - Replace hardcoded get_site_url(wu_get_main_site_id()) with get_home_url() using the stored checkout blog ID (falls back to main site for existing customers) - Add wu_customer_verification_base_url filter for full control
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThe changes persist the current WordPress blog ID to newly created customers during checkout. Customer verification URLs now derive their base URL from this stored blog ID instead of always defaulting to the main site, enabling verification emails to reference the originating checkout domain. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
|
Performance Test Results Performance test results for 479e051 are in 🛎️! Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown. URL:
|
Summary
example2.combut the verification email links toexample.com, causing an authentication failure when clicking the linkProblem
When a checkout form lives on a domain other than the main site (e.g.
example2.com), the verification email always linked to the main site (example.com). The customer's auth cookie was set for the checkout domain duringlogin_customer_after_checkout(), so clicking the verification link on the main site hit theis_user_logged_in()guard inmaybe_verify_email_address()and died with a login prompt — on the wrong domain.Changes
inc/models/class-customer.phpMETA_CHECKOUT_BLOG_IDconstant (wu_checkout_blog_id)get_checkout_blog_id()/set_checkout_blog_id()methods using existing meta systemget_verification_url()to useget_home_url($blog_id)with the stored checkout blog ID, falling back towu_get_main_site_id()for existing customers without the metawu_customer_verification_base_urlfilter for full override controlinc/checkout/class-checkout.phpmaybe_create_customer(), storeget_current_blog_id()on the customer before the verification email is triggeredBackward Compatibility
Existing customers without the meta key get
0fromget_checkout_blog_id(), which is falsy, so the fallback towu_get_main_site_id()preserves the old behavior. No database migration needed.aidevops.sh v3.13.3 plugin for OpenCode v1.3.17 with claude-opus-4-6 spent 15m and 23,186 tokens on this with the user in an interactive session.
Summary by CodeRabbit