How to add some html/js code to pages via hooks

From aMember Pro Documentation
Revision as of 04:56, 5 February 2016 by Caesar (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Add this code to site.php file:

Am_Di::getInstance()->hook->add(Am_Event::AFTER_RENDER, function (Am_Event_AfterRender $event) {
    if (preg_match('#^/amember/helpdesk/index.*#i', $_SERVER['REQUEST_URI'])) //do it only for specific url
    {
        $event->replace('#(<h1>Tickets.*</h1>)#i', '$1<div>Some content</div>');
    }
});