Checking Session for Multiple Prod ID's Before displaying code...

Discussion in 'Customization & add-ons' started by tim_erwa1, Feb 14, 2007.

  1. tim_erwa1

    tim_erwa1 New Member

    Joined:
    Aug 22, 2006
    Messages:
    7
    Can someone tell me the correct syntax for checking a members session for multiple Product ID's before displaying code?

    Something like...
    <?php

    include('../amember/config.inc.php');
    $_product_id = array('ONLY_LOGIN');

    require($config['plugins_dir']['protect'] . '/php_include/check.inc.php');

    if($_SESSION[_amember_user][data][status][7]){
    // I want the line above to check against multiple products like 7,9,10 rather than just 7.
    header ("Location: /members/IPA/welcome-index.php"); exit;
    }
    // and then I want the code displayed here if logged member meets the above criteria

    //then place an else statment here to redirect them to a sales page if they dont meet the if criteria.

    The key ingredient here is code that I can place at the top of any page to either show the content or not depending on access, but again I want to check against multiple product id's because the same content may be offered in several product groups.

    Thanks in advance for any assistance.

    JPJ:confused:
  2. tacit

    tacit CGI-Central Support

    Joined:
    Nov 23, 2006
    Messages:
    12
    Hello Tim
    Is this what you need ?

    $same_products = array(7,9,10);
    foreach ((array)$_SESSION[_amember_user][data][status] as $product_id => $status){
    if ($status && in_array($product_id,$same_products)){
    $too_bad = true;
    }
    }
    if ($too_bad)
    header ("Location: /amember/signup.php");
    else
    header ("Location: /members/IPA/welcome-index.php");
  3. tim_erwa1

    tim_erwa1 New Member

    Joined:
    Aug 22, 2006
    Messages:
    7
    Much appreciated.... I beleive tht is what I am looking for.

    However rather than a redirect here >

    header ("Location: /members/IPA/welcome-index.php");

    How can I have it execute page code rather than use the header tag?

    JPJ :D
  4. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    You can insert code execution and brackets instead of "header" function call.

Share This Page