Difference between revisions of "How to add/remove link in "Useful Links" block"

From aMember Pro Documentation
Jump to: navigation, search
 
(3 intermediate revisions by one user not shown)
Line 2: Line 2:
 
<source>
 
<source>
 
<?php  
 
<?php  
Am_Di::getInstance()->hook->add(Am_Event::GET_MEMBER_LINKS, function (Am_Event $event){
+
Am_Di::getInstance()->hook->add(Am_Event::GET_MEMBER_LINKS, function (Am_Event $e){
     $event->addReturn('LINK TITLE', '/url/');
+
     $e->addReturn('LINK TITLE', '/url/');
 +
    $e->addReturn('LINK TITLE 2', '/url2/');
 
});
 
});
 
</source>
 
</source>
Line 12: Line 13:
 
Am_Di::getInstance()->hook->add(Am_Event::GET_MEMBER_LINKS, function(Am_Event $e){
 
Am_Di::getInstance()->hook->add(Am_Event::GET_MEMBER_LINKS, function(Am_Event $e){
 
     $ret = $e->getReturn();
 
     $ret = $e->getReturn();
     foreach($ret as $k=>$v)
+
     foreach($ret as $k=>$v) {
         if(strpos($k, 'payment-history')!==false)
+
         if(strpos($k, 'payment-history')!==false) {
 
             unset($ret[$k]);
 
             unset($ret[$k]);
 +
        }
 +
    }
 
     $e->setReturn($ret);
 
     $e->setReturn($ret);
 
});
 
});
 
</source>
 
</source>

Latest revision as of 05:14, 17 December 2016

In order to create own link, add this code to site.php file:

<?php 
Am_Di::getInstance()->hook->add(Am_Event::GET_MEMBER_LINKS, function (Am_Event $e){
    $e->addReturn('LINK TITLE', '/url/');
    $e->addReturn('LINK TITLE 2', '/url2/');
});

In order to remove link use this code (example is to remove "Payment History" link):

<?php
Am_Di::getInstance()->hook->add(Am_Event::GET_MEMBER_LINKS, function(Am_Event $e){
    $ret = $e->getReturn();
    foreach($ret as $k=>$v) {
        if(strpos($k, 'payment-history')!==false) {
            unset($ret[$k]);
        }
    }
    $e->setReturn($ret);
});