Dynamic hyperlinks Based on aMember subscription status

Discussion in 'Customization & add-ons' started by nlnsta, Sep 10, 2004.

  1. nlnsta

    nlnsta Guest

    Hi all,

    I hope someone can help with my little quandary!

    Okay, I have a situation where I have one page: "Page1", that needs to link to "Page2" ONLY if the user has an active subscription to an aMember product, say: "Product5". If they do NOT have an active subscription to "Product5" then they would need to be linked to "Page3" instead.

    Schematically this would read:
    ________________________________________________________

    IF $member has subscription to [Product5] with [status of 1],

    create 'hyperlink to Page2'

    else

    create 'hyperlink to Page3'

    If someone could help with the correct syntax of this, I would be extremely appreciative as this is a rather urgent and important requirement - and I am really stuck!

    Thanks,
    Matt.
    Sydney Swingers
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    I hope it is a PHP page already protected by aMember. If so, do the following:

    PHP:
    if (in_array(5$_SESSION['_amember_product_ids']))
     print 
    "<a href='page_2.html'>Page 2</a>";
    else
     print 
    "<a href='page_3.html'>Page 3</a>";
  3. nlnsta

    nlnsta Guest

    Thanks Alex.

    Once again you have come through for me - it works perfectly. :)

    One additional question: can this be done with multiple products? For example: if (in_array(5,6,7, $_SESSION['_amember_product_ids'])) I know this doesn't work (already tried) but I am wondering if it can be done using multiple products as I now have three products (5,6,7) and my members need at least ONE of the three to get the Page2.html url.
    If it can't be done, no problems - just curious.

    Thanks again Alex,
    Matt.
    Sydney Swingers
  4. nlnsta

    nlnsta Guest

    It's alright Alex - I worked out how to do it with multiple products. Probably not the neatest way to code - but it works:

    if (in_array(5, $_SESSION['_amember_product_ids']))
    print "<a href='Page2.php'>OCTOBER EVENT - REGISTRATION PAGE</a>";
    else
    if (in_array(6, $_SESSION['_amember_product_ids']))
    print "<a href='Page2.php'>OCTOBER EVENT - REGISTRATION PAGE</a>";
    else
    if (in_array(7, $_SESSION['_amember_product_ids']))
    print "<a href='Page2.php'>OCTOBER EVENT - REGISTRATION PAGE</a>";
    else
    print "<a href='Page3.php'>OCTOBER EVENT - PAYMENT PAGE</a>";

    Thanks again,
    Matt

Share This Page