Finding expired subscriptions

Discussion in 'Customization & add-ons' started by burtonkent, Jan 17, 2010.

  1. burtonkent

    burtonkent aMember Pro Customer

    Joined:
    Jul 2, 2009
    Messages:
    7
    This has been a real problem for me, I've been trying to figure it out for two days.

    I want to be able to have a user log into a page, then I'll look up what products/subscriptions expired. Then I'll offer them a renewal. But it I just haven't been able to find a way to find expired products/subscriptions.

    Seems like amember will email about subscriptions, but I'm not seeing any way to programmatically find out what subscriptions are expired. If it's expired, both $_SESSION['_amember_products'] and $_SESSION['_amember_subscriptions'] are empty. So I end up with nothing to work with.

    Any pointers?:confused:
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Both these session vars will not have expired products.
    You should use MySQL database to query users expired payments :
    Code:
    include "config.inc.php";
    $q = $db->query("select * from amember_payments where completed =1 and member_id ='".$_SESSION["_amember_id"]."' and begin_date<=now() and expire_date <=now()");
    while($payment = mysql_fetch_assoc($q)){
    $payment['data'] = unserialize($payment['data']);
    $expired[] = $payment; 
    }
    
    So $expired will have only expired payments for this user.

Share This Page