I'm building a membership site where users must only have one active subscription at a time. I would like that on a purchase of any new subscription/product all other subscriptions to be cancelled/expired and all associated membership deleted/cancelled. Only the latest subscription should remain active with its accompanying membership.
I cannot/don't want to use the built-in function to limit subscriptions for several reasons.
Is there any way that on the thank you page, a snipped loops in all active subscriptions from current user and cancel/expire them, except for the one that has been just bought?
I've checked this post which looks similar but no real solution was provided (WooCommerce Subscriptions - Only Allow user one active subscription)
Thanks a lot for your help
Best regards