Difference between revisions of "How to customize user tabs in member's area"

From aMember Pro Documentation
Jump to: navigation, search
Line 1: Line 1:
Let's say you want to add a tab to the member's area and remove the Add/Renew tab.  
+
Let's say you want to add a tab to the member's area and remove the Add/Renew tab.
 
+
 
+
Add this code to /amember/application/configs/site.php:
+
  
 +
Add this code to [[site.php file]]:
 
<source>
 
<source>
 
<?php
 
<?php

Revision as of 03:32, 9 August 2013

Let's say you want to add a tab to the member's area and remove the Add/Renew tab.

Add this code to site.php file:

<?php
Am_Di::getInstance()->hook->add('userMenu', 'siteUserMenu');
function siteUserMenu(Am_Event $event)
{
      // $user = $event->getUser(); // if required
      $menu = $event->getMenu();
 
      // Add a tab
      $menu->addPage(array(
              'id' => 'mypage',
              'label' => ___('Do The Thing'),
              'uri' => '/the.thing',
              'order' => 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,
       ));
 
}