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

From aMember Pro Documentation
Jump to: navigation, search
 
Line 1: Line 1:
 
In order to create own link, add this code to [[site.php file]]:
 
In order to create own link, add this code to [[site.php file]]:
 
<source>
 
<source>
<?php
 
 
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){
 
     $e->addReturn('LINK TITLE', '/url/');
 
     $e->addReturn('LINK TITLE', '/url/');
Line 10: Line 9:
 
In order to remove link use this code (example is to remove "Payment History" link):
 
In order to remove link use this code (example is to remove "Payment History" link):
 
<source>
 
<source>
<?php
 
 
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();

Latest revision as of 07:44, 10 July 2018

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


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):


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);
});