Helper methods for CBSubs

3 years 7 months ago #320553 by fdinkler
Helper methods for CBSubs was created by fdinkler
I'm writing a restful interface to a mobile app, so there's no UI involved.
One of the login returns is the user's membership expiration date.
I can write my own method against the cbsubs_subscription table, but I'd prefer to use an existing method if there's one available.
Since CBSubs tab shows the current expiration, I suspect such methods exist.
Any help?
Thanks,
Fred

Please Log in to join the conversation.

3 years 7 months ago #320566 by krileon
Replied by krileon on topic Helper methods for CBSubs
Your fastest approach is to just query for it. There isn't any additional processing on expiration date (beyond formatting) to necessitate going through APIs for it. If you still want to do this through API you can get a list of a users active subscriptions using the below.

Active Subscriptions:
$subscriptions = cbpaidUserExtension::getInstance( USER_ID_HERE )->getActiveSubscriptions();

If you also want to get all subscriptions, even those expired, then you can use the below.

All Subscriptions:
$subscriptions = cbpaidUserExtension::getInstance( USER_ID_HERE )->getUserSubscriptions();


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.180 seconds

Facebook Twitter LinkedIn