How to add a tab based on 'CATEGORY' access

Discussion in 'Customization & add-ons' started by gennaro_montone, Jan 15, 2016.

Thread Status:
Not open for further replies.
  1. gennaro_montone

    gennaro_montone aMember Pro Customer

    Joined:
    Jul 8, 2012
    Messages:
    17
    Hello,
    I'm customizing the TABS, and everything is ok following this code:

    //Add a tab based on user access, if user has active subscription to product with # 1
    /* @var $user User */
    $user = $event->getUser();
    if (in_array(1, $user->getActiveProductIds())) {
    $menu->addPage(array(
    'id' => 'mypage',
    'label' => ___('Do The Thing'),
    'uri' => '/the.thing',
    'order' => 2,
    ));

    But what is I want to add a tab based on 'CATEGORY' access?
    I See that "getActiveCategoryIds()" doesn't exist.. am I wrong?

    Thanks
    Ciro
  2. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,669
    You can use code:
    PHP:
    $cat_product Am_Di::getInstance()->productCategoryTable->getCategoryProducts();

    if (
    array_intersect($user->getActiveProductIds(), $cat_product[1])) {
        
    //do some stuff, 1 is id of your category
    }
  3. gennaro_montone

    gennaro_montone aMember Pro Customer

    Joined:
    Jul 8, 2012
    Messages:
    17
    Thank you Caesar!
Thread Status:
Not open for further replies.

Share This Page