get current active subscription and status?

Discussion in 'Integration' started by easyprompter, Feb 3, 2018.

  1. easyprompter

    easyprompter aMember Pro Customer

    Joined:
    Oct 4, 2016
    Messages:
    22
    I have 3 different subscription levels. 1 free and 2 paid (one monthly, one yearly).
    For any logged in user, i'd like to be able to immediately tell they active subscription and whether it's active. Often times I have users that were free that then converted. Sometimes they'll do a year of yearly and then move to monthly. Current methods available seem overly complicated in terms of figuring out the current status.

    Is there a simple way to tell this info? I'm not interested in their past subscriptions.
  2. easyprompter

    easyprompter aMember Pro Customer

    Joined:
    Oct 4, 2016
    Messages:
    22
    Oh and I'm ok doing this with sql if that's what it takes
  3. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,830
    Hello,

    In event of you are inside aMember codebase then you can get array of user active product ids with this code:
    Code:
    Am_Di::getInstance()->user->getActiveProductIds();
    Outside of aMember codebase you can utilize Lite API:
    http://www.amember.com/docs/API/Lite
    Code:
    Am_Lite::getInstance()->haveSubscriptions(1);
    //returns true if user have active subscription to product with id 1
    With SQL you can do this query:
    Code:
    SELECT product_id FROM am_user_status WHERE user_id=2 AND status=1;
    where 2 is id of any user and 1 is status active

    Best Regards.
  4. easyprompter

    easyprompter aMember Pro Customer

    Joined:
    Oct 4, 2016
    Messages:
    22
    any way to easily get "first login after registration" ?
  5. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,830
    You can set some field to user table once user signup and then check it and clear on first login.

Share This Page