A WooCommerce-powered WordPress site encountered a critical issue: customers who successfully purchased a course were seeing it marked as “expired” immediately upon checkout. This was traced back to the way a custom plugin handled user roles, especially when guest checkout was disabled.
Issue background
The site used WooCommerce to sell access to online courses. After turning off guest checkout, users were required to create a username and password during the purchase process.
However, a newly created account would trigger the course status to show as “expired,” despite successful order completion. This issue was isolated to the live site—on staging, courses were assigned properly post-purchase.
The client had installed the “User Switching” plugin to aid in testing, and the affected logic was tied to a custom plugin named “SuperTest SP.”
Diagnosis
The root cause was found within the custom plugin logic, which determined whether a user had active access based on their role and order history. Specifically:
- The logic responsible for flagging “expired” or “active” access didn’t account for the delay between user creation and order processing.
- If a user was created and immediately evaluated before the WooCommerce order meta was properly saved, the plugin incorrectly marked the purchase as expired.
- The staging environment avoided this issue due to slight differences in timing or processing speed.
Resolution steps
- Replicated issue using test accounts: Leveraged the “User Switching” plugin to test multiple user states.
- Reviewed plugin code: Located the function that checked course expiration status based on user metadata and WooCommerce order status.
- Modified logic to defer access evaluation until order completion and proper role assignment.
- Validated fix in staging: Confirmed that new accounts now correctly showed course access as “active” immediately post-checkout.
- Pushed update to live site.
Final outcome
The fix resolved the immediate issue of course access being incorrectly denied after purchase. New customers now see their purchased courses marked as “active” upon account creation and checkout completion.
For any WooCommerce site handling digital access or gated content, timing and user role logic is critical. If you’re experiencing similar issues with order-triggered access or membership logic, contact Freshy—we’ll help ensure your site handles user transitions smoothly and accurately.