Product Category And Protected Files

Discussion in 'aMember Pro v.4' started by kinitex, Oct 3, 2012.

  1. kinitex

    kinitex Member

    Joined:
    Aug 28, 2009
    Messages:
    50
    I have 2 products in a product category, and I want to give this category access to a protected file ONLY IF the user is subscribed to BOTH products in that category. Not just 1 of them.

    How can this be done? I'm willing to do some code hacks or sql hacks if neccessary but will need help.
  2. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    Hack would be needed., although maybe you can test putting protection on a subdirectory.
    eg protect /1/ with product 1, then /1/2/ with product 2 and maybe you can only get into /2/ if you have both 1 and 2. (untested)

    David
  3. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    David, I am afraid this solution would not work.

    You can do PHP check for this, using either LITE API, REST API, or full aMember API.
    Sample with Lite Api:
    PHP:
    require_once 'amember/library/Am/Lite.php';
    $liteApi Am_Lite::getInstance();
    if (
    $liteApi->haveSubscriptions(9) && $liteApi->haveSubscriptions(11))
    {
         echo 
    "You have access to both product 9 and product 11";
    } else {
         die(
    "No Access to either product 9 or product 11!");
    }
  4. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    Think you can do this too to make it easier?

    $check= array(1,2,3,4,5)

    $liteApi->haveSubscriptions($check)

    David
    frybread likes this.
  5. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    David,
    That will return true if user have subscription to any product included in array. Code with was suggested by Alex should be used if user must have both subscriptions.

Share This Page