Find subscription number

Discussion in 'Customization & add-ons' started by mdmr_llc, Aug 29, 2008.

  1. mdmr_llc

    mdmr_llc Member

    Joined:
    Aug 22, 2006
    Messages:
    62
    I need to be able to detect what subscription a user has. In fact I am looking for a particular one.

    I used the following:

    if (in_array(2, $_SESSION[_amember_product_ids])) {
    ...
    }

    But it only works if the account is active. If it expires the array is blank. I need to know what that account is whether it is active or expired. I think it is possible but not sure how.

    Thanks.
  2. jimjwright

    jimjwright New Member

    Joined:
    Sep 12, 2007
    Messages:
    162
    Hello,

    The following function will return all product ids. You can specify 1 for $only_completed if you only want products that they have paid for. You specify 0 for $ only_completed if you want all products even those that they started to purchase but didn't complete payment on.

    PHP:
    function get_user_products($member_id$only_completed)
    {
      global 
    $db;

      
    $user_product_ids = array('');
      foreach (
    $db->get_user_payments($member_id$only_completed) as $p)
      {
        
    $user_product_ids[] = $p['product_id']; 
      }
      
    $user_product_ids array_unique($user_products_ids);
      return 
    $user_product_ids;
    }
    Jimmy

Share This Page