Hi, Right now when one of my members logs in they can see the follow tabs in their membership area: Main Page, Add/Renew Subscription, Payments History, Edit Profile, Affiliate Info, and Helpdesk. How can I edit these? I just want it to have tabs for Main Page, Edit Profile, and Helpdesk. Thanks for the help.
Instructions in wiki: http://www.amember.com/docs/How_to_customize_user_tabs_in_member's_area David, at Membership Academy, also has a video describing the process.
I too am interested in this but can't see where the site.php file is placed can anyone help? I found the file site-dist.php and renamed this as instructed to site.php. I then uploaded the code as per the information above only to get an error message.
<?php Am_Di::getInstance()->hook->add('userMenu', 'siteUserMenu'); function siteUserMenu(Am_Event $event) { // $user = $event->getUser(); // if required $menu = $event->getMenu(); // Add a single tab $menu->addPage(array( 'id' => 'mypage', 'label' => ___('Do The Thing'), 'uri' => '/the.thing', 'order' => 2, )); // Add a tab with subitems $menu->addPage( array( 'id' => 'with-subitem', 'label' => 'With Subitems', 'uri' => '#', 'pages' => array( array( 'id' => 'subitem1', 'label' => 'Subitem 1', 'uri' => '/subitem-2' ), array( 'id' => 'subitem2', 'label' => 'Subitem 2', 'uri' => '/subitem-2' ) ) ) ); // Remove a tab $page = $menu->findOneBy('id', 'add-renew'); $menu->removePage($page); // Add sub item to exiting tab $page = $menu->findOneBy('id', 'aff'); // get affiliate page $page->addPage(array( 'id' => 'my-subitem', 'label' => ___('Subitem'), 'uri' => '/sub.item', 'target' => '_blank', // you can set target attribute if necessary 'order' => 10, )); //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, )); } }
it was yes. the error was: Fatal error: Call to a member function addPage() on a non-object in /home/pdhub/public_html/coaching4everyone/amember/application/configs/site.php on line 43
Please use this code instead Code: <?php Am_Di::getInstance()->hook->add('userMenu', 'siteUserMenu'); function siteUserMenu(Am_Event $event) { // $user = $event->getUser(); // if required $menu = $event->getMenu(); // Add a single tab $menu->addPage(array( 'id' => 'mypage', 'label' => ___('Do The Thing'), 'uri' => '/the.thing', 'order' => 2, )); // Add a tab with subitems $menu->addPage( array( 'id' => 'with-subitem', 'label' => 'With Subitems', 'uri' => '#', 'pages' => array( array( 'id' => 'subitem1', 'label' => 'Subitem 1', 'uri' => '/subitem-2' ), array( 'id' => 'subitem2', 'label' => 'Subitem 2', 'uri' => '/subitem-2' ) ) ) ); // Remove a tab $page = $menu->findOneBy('id', 'add-renew'); $menu->removePage($page); //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, )); } }
I do want to remove the payment history tab and found this code. which works. but combining your code and this together I get an error can you please explain using your code what I need to do to remove the payment history tab please. sarah x <?php Am_Di::getInstance()->hook->add(Am_Event::GET_MEMBER_LINKS, 'getLinks'); function getLinks(Am_Event $event){ $event->addReturn('e-Coaching Area', 'http://coaching4everyone.pd-hub.com'); } if (!defined('INCLUDED_AMEMBER_CONFIG')) die("Direct access to this location is not allowed"); /* * aMember Pro site customization file * * Rename this file to site.php and put your site customizations, * such as fields additions, custom hooks and so on to this file * This file will not be overwritten during upgrade * */ Am_Di::getInstance()->hook->add('userMenu', 'siteUserMenu'); function siteUserMenu(Am_Event $event) { // $user = $event->getUser(); // if required $menu = $event->getMenu(); // remove a page $page = $menu->findOneBy('id', 'add-renew'); $menu->removePage($page); // remove a page $page = $menu->findOneBy('id', 'payment-history'); $menu->removePage($page); }
Both codes work individually. But I would like to use your code but remove the payment history tab. Sarah
Yes, I got it. I mean what exactly you want to implement with code from example. Example code has many example I do not think you actually need all of them. But if you want to incorporate all code it will be Code: <?php if (!defined('INCLUDED_AMEMBER_CONFIG')) die("Direct access to this location is not allowed"); /* * aMember Pro site customization file * * Rename this file to site.php and put your site customizations, * such as fields additions, custom hooks and so on to this file * This file will not be overwritten during upgrade * */ Am_Di::getInstance()->hook->add(Am_Event::GET_MEMBER_LINKS, 'getLinks'); function getLinks(Am_Event $event) { $event->addReturn('e-Coaching Area', 'http://coaching4everyone.pd-hub.com'); } Am_Di::getInstance()->hook->add('userMenu', 'siteUserMenu'); function siteUserMenu(Am_Event $event) { // $user = $event->getUser(); // if required $menu = $event->getMenu(); // remove a page $page = $menu->findOneBy('id', 'add-renew'); $menu->removePage($page); // remove a page $page = $menu->findOneBy('id', 'payment-history'); $menu->removePage($page); // Add a single tab $menu->addPage(array( 'id' => 'mypage', 'label' => ___('Do The Thing'), 'uri' => '/the.thing', 'order' => 2, )); // Add a tab with subitems $menu->addPage( array( 'id' => 'with-subitem', 'label' => 'With Subitems', 'uri' => '#', 'pages' => array( array( 'id' => 'subitem1', 'label' => 'Subitem 1', 'uri' => '/subitem-2' ), array( 'id' => 'subitem2', 'label' => 'Subitem 2', 'uri' => '/subitem-2' ) ) ) ); //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, )); } }
Using code like the above, how do we make the selected tab stay highlighted when selected, like the default tabs? Do we need another option 'activeClass' => 'active' or similar? any help greatly appreciated
You need to detect somehow that your page is active now and then use this code to set it active Code: $menu->findOneBy('id', 'mypage')->setActive(true);