Hiding products from dashboard

Discussion in 'Customization & add-ons' started by bennyuk1, Jun 26, 2017.

  1. bennyuk1

    bennyuk1 aMember Pro Customer

    Joined:
    Jan 12, 2012
    Messages:
    200
    I have some products that I use for admin purposes that I want to hide from the users dashboard, specifically under "Expired Products". Can this be done?
  2. bennyuk1

    bennyuk1 aMember Pro Customer

    Joined:
    Jan 12, 2012
    Messages:
    200
    I have "Expired Products" via edit to site.php

    Am_Di::getInstance()->blocks->add(
    new Am_Block(
    'member/main/left',
    'Expired Subscriptions',
    'expired-sub',
    null,
    function (Am_View $v) {
    $out = array();
    foreach (Am_Di::getInstance()->user->getExpiredProducs() as $p) {
    $out[] = sprintf('<li>%s</li>', Am_Html::escape($p->title));
    }
    return sprintf('<ul class="am-widget-list">%s</ul>', implode("\n", $out));
    }));
  3. bennyuk1

    bennyuk1 aMember Pro Customer

    Joined:
    Jan 12, 2012
    Messages:
    200
    sorted, hid it by adding CSS ID from product ID

    Am_Di::getInstance()->blocks->add(
    new Am_Block(
    'member/main/left',
    'Expired Subscriptions',
    'expired-sub',
    null,
    function (Am_View $v) {
    $out = array();
    foreach (Am_Di::getInstance()->user->getExpiredProducs() as $p) {
    $out[] = sprintf('<li id="exproduct-item-%s">%s</li>', ($p->pk()), Am_Html::escape($p->title));
    }
    return sprintf('<ul class="am-widget-list">%s</ul>', implode("\n", $out));
    }));
  4. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    I believe you can just do not add it from code at first place:
    PHP:
    foreach (Am_Di::getInstance()->user->getExpiredProducs() as $p) {
        if (
    in_array($p->pk(), array(1,2,3))) continue;
        
    $out[] = sprintf('<li id="exproduct-item-%s">%s</li>', ($p->pk()), Am_Html::escape($p->title));
    }
    where 1,2,3 is ids of your admin products

    Best Regards.

Share This Page