Hello, Could someone please tell me how to add multiple new tabs to the members and assign pages to them? I can use this in the site.php file to create 1 new tab correctly: <?php Am_Di::getInstance()->hook->add(Am_Event::USER_MENU, 'onUserMenu'); function onUserMenu(Am_Event $event) { $event->getMenu()->addPage( array( 'id' => 'pageid', 'label' => 'Button label', 'uri' => '/test/url', 'order' => 1000 ) ); } ?> But the question is, how do I create more tabs? How can I also create dropdowns from tabs in the members area? Thank you!
Hey, You can add as many tabs as you want same way. In order to set up sub tabs you need to use additional array with key pages. Here example of code for you: PHP: Am_Di::getInstance()->hook->add(Am_Event::USER_MENU, 'onUserMenu'); function onUserMenu(Am_Event $event){ $event->getMenu()->addPage( array( 'id' => 'pageid', 'label' => 'Button label', 'uri' => '/test/url', 'order' => 1000 ) ); $event->getMenu()->addPage( array( 'id' => 'otherpageid', 'label' => 'Other Button label', 'uri' => '/other/test/url' ) ); $event->getMenu()->addPage( array( 'id' => 'subitemspageid', 'label' => 'With Subitems', 'uri' => '#', 'pages' => array( array( 'id' => 'subitem1', 'label' => 'Subitem 1', 'uri' => '/subitem-2' ), array( 'id' => 'subitem2', 'label' => 'Subitem 2', 'uri' => '/subitem-2' ) ) ) );}
Just to hijack this thread for a bit is it possible to remove a Tab and replace it with another but just for a specific product?
Hey Ceasar, Thanks again, one last thing if you could. In regards to the code you sent above, which does work perfectly. What would I need to add to that code, to add a submenu item to an existing tab. Such as adding a dropdown menu option to the existing Payments History Tab? Thank you!
Dear friends, I updated manual page and added example of code to add tab based on user active subscription. Also you can find example how to add subitems to existing tab. Id of Payments History Tab is payment-history http://www.amember.com/docs/How_to_customize_user_tabs_in_member's_area
You can find example in link that I gave before. Anyway here is example of code to remove add/renew tab if user has active subscription to product with #1. Code: Am_Di::getInstance()->hook->add('userMenu', 'siteUserMenu'); function siteUserMenu(Am_Event $event) { $menu = $event->getMenu(); $user = $event->getUser(); if (in_array(1, $user->getActiveProductIds())) { $page = $menu->findOneBy('id', 'add-renew'); $menu->removePage($page); } }