I have a paid and a free tier - the products are in "free" or "paid" categories. How do I easily determine whether the currently logged in user is in one of the tiers? I'd prefer not to check each product id but basically get "current category" I'm open to either Lite or REST Thanks
Hello, Lite API has two option that you can use. 1. It have const PHP: Am_Lite::PAID and you can use it as search condition: PHP: Am_Lite::getInstance()->haveSubscriptions(Am_Lite::PAID); 2. Another option Am_Lite has method to retrieve product_ids from specific category: PHP: $pids = Am_Lite::getInstance()->getCategoryProducts(1); You can use this $pids array to check access then: PHP: Am_Lite::getInstance()->haveSubscriptions($pids); Best Regards.
Interestingly enough, the AM_LiteAID thing didn't work for me - it gave me backwards results, but the latter approach is working - thanks! What about detecting when a subscription has expired or unpaid?
First approach works in case user actually pay for access. I guess you just added access to paid product manually from admin interface, is not it? Lite API has method that allow to check whether user had access before: PHP: Am_Lite::getInstance()->hadSubscriptions($search)
That's correct - I added access manually. However, I'd like to know the basic "tier" the person is in regardless of how it was added. Here's what i'm doing: PHP: $pids = Am_Lite::getInstance()->getCategoryProducts(2); //paid $isPaid = Am_Lite::getInstance()->haveSubscriptions($pids); $isActive = Am_Lite::getInstance()->isUserActive(); if ($isPaid && $isActive) { //do stuff for paid active users } My question is
So after more testing, here's an issue I have with the above code. I add a free subscription, i then add a paid subscription. i then cancel the paid one. the code above still returns true. How can i evaluate the tier that's current and not canceled/expired/disabled?
hmm ok so my mistake - my paid tier includes a 14 day trial .. once that date passes, it works as expected.