Hooks

Getting Started with Hooks

Hooks are the additional functions that execute when associated events occur in Mumara. Learn how to create and execute your additional code in Mumara hooks.

Creating a Hook File

Hooks functions are written into PHP files and are placed inside /includes/hooks/ folder (or /Addons/your_addon/hooks.php in the case of an add-on). You'll find an example.php file placed inside /includes/hooks/ folder with the example code. The file name could be any name e.g. myfirsthook.php or aftercontactadd.php.

So let's create a sample hook for testing purposes

touch ~/includes/hooks/myfirsthook.php

Add a Sample Hook Function

Below is a sample hook function that will execute when a contact is added.

<?php/** * Register a hook * * AddContact: The hook function to listen when a contact is added * 1: The priority to sort the multiple executions * Function: Function to be called * */ add_hook('AddContact',1, function($vars) {		echo "<pre>";    $data = "Hello World";	file_put_contents('storage/hello.txt', $data, FILE_APPEND | LOCK_EX);	});

The above hook function will create a hello.txt file in the /storage folder when a contact is added to any list. Most of the hooks return all values in $vars that can be useful in creating your codes that require the affected data and their values. You can use print_r($vars, true) to write all of the returned values to a file.

Recommendation!
While using a named function, we suggest you double-check for any conflicts. The best way is to use named functions with a prefix.

Priority

Every hook needs a priority to be defined to arrange the sorting order for the executions when there are several hooks registered for the same event.

Note:
The priority has to be an integer value.

Module Hooks

These hooks run on the events related to the module actions.

AddContactList

It executes when a contact list has been created successfully.

Example Code

<?phpadd_hook('AddContactList',1, function($vars) {	// Your code here});

EditContactList

It executes when a contact list has been edited.

Example Code 

<?phpadd_hook('EditContactList',1, function($vars) { 	// Your code here});

DeleteContactList

It executes when a contact list has been deleted.

Example Code

<?phpadd_hook('DeleteContactList',1, function($vars) { 	// Your code here });

ImportList

It executes when a contact list has been imported.

Example Code 

<?phpadd_hook('ImportList',1, function($vars) { 	// Your code here });

ExportList

It executes when a contact list has been exported.

Example Code

<?phpadd_hook('ExportList',1, function($vars) { 	// Your code here });

AddContact

It executes when a contact has been added.

Example Code

<?phpadd_hook('AddContact',1, function($vars) {	// Your code here });

EditContact

It executes when a contact has been edited.

Example Code

<?phpadd_hook('EditContact',1, function($vars) {	// Your code here});

DeleteContact

It executes when a contact has been deleted.

Example Code

<?phpadd_hook('DeleteContact',1, function($vars) {	// Your code here});

AddCustomField

It executes when a custom field has been added.

Example Code

<?phpadd_hook('AddCustomField',1, function($vars) {	// Your code here});

EditCustomField

It executes when a custom field has been edited.

Example Code

<?phpadd_hook('EditCustomField',1, function($vars) {	// Your code here});

DeleteCustomField

It executes when a custom field has been deleted.

Example Code

<?phpadd_hook('DeleteCustomField',1, function($vars) {	// Your code here});

AddSegment

It executes when a segment has been created.

Example Code

<?phpadd_hook('AddSegment',1, function($vars) {	// Your code here});

DeleteSegment

It executes when a segment has been deleted.

Example Code

<?phpadd_hook('DeleteSegment',1, function($vars) {	// Your code here});

RecountSegment

It executes when a segment has been recounted.

Example Code

<?phpadd_hook('RecountSegment',1, function($vars) {	// Your code here});

ExportSegment

It executes when a segment has been exported.

Example Code

<?phpadd_hook('ExportSegment',1, function($vars) {	// Your code here});

AddBroadcast

It executes when a broadcast has been added.

Example Code

<?phpadd_hook('AddBroadcast',1, function($vars) {	// Your code here});

EditBroadcast

It executes when a broadcast has been edited.

Example Code

<?phpadd_hook('EditBroadcast',1, function($vars) {	// Your code here});

DeleteBroadcast

It executes when a broadcast has been deleted.

Example Code

<?phpadd_hook('DeleteBroadcast',1, function($vars) {	// Your code here});

AddDripGroup

It executes when a drip group has been added.

Example Code

<?phpadd_hook('AddDripGroup',1, function($vars) {	// Your code here});

EditDripGroup

It executes when a drip group has been edited.

Example Code

<?phpadd_hook('EditDripGroup',1, function($vars) {	// Your code here});

DeleteDripGroup

It executes when a drip group has been deleted.

Example Code

<?phpadd_hook('DeleteDripGroup',1, function($vars) {	// Your code here});

AddDrip

It executes when a drip has been added.

Example Code

<?phpadd_hook('AddDrip',1, function($vars) {	// Your code here});

EditDrip

It executes when a drip has been edited.

Example Code

<?phpadd_hook('EditDrip',1, function($vars) {	// Your code here});

DeleteDrip

It executes when a drip has been deleted.

Example Code

<?phpadd_hook('DeleteDrip',1, function($vars) {	// Your code here});

AddSplitTest

It executes when a split test has been created.

Example Code

<?phpadd_hook('AddSplitTest',1, function($vars) {	// Your code here});

EditSplitTest

It executes when a split test has been edited.

Example Code

<?phpadd_hook('EditSplitTest',1, function($vars) {	// Your code here});

DeleteSplitTest

It executes when a split test has been deleted.

Example Code

<?phpadd_hook('DeleteSplitTest',1, function($vars) {	// Your code here});

AddSpinTag

It executes when a spintag has been added.

Example Code

<?phpadd_hook('AddSpinTag',1, function($vars) {	// Your code here});

EditSpingTag

It executes when a spintag has been edited.

Example Code

<?phpadd_hook('EditSpingTag',1, function($vars) {	// Your code here});

DeleteSpinTag

It executes when a spintag has been deleted.

Example Code

<?phpadd_hook('DeleteSpinTag',1, function($vars) {	// Your code here});

AddDynamicContentTag

It executes when a dynamic content tag has been added.

Example Code

<?phpadd_hook('AddDynamicContentTag',1, function($vars) {	// Your code here});

EditDynamicContentTag

It executes when a dynamic content tag has been edited.

Example Code

<?phpadd_hook('EditDynamicContentTag',1, function($vars) {	// Your code here});

DeleteDynamicContentTag

It executes when a dynamic content tag has been deleted.

Example Code

<?phpadd_hook('DeleteDynamicContentTag',1, function($vars) {	// Your code here});

ScheduleBroadcast

It executes when a broadcast has been scheduled.

Example Code

<?phpadd_hook('ScheduleBroadcast',1, function($vars) {	// Your code here});

RescheduleBroadcast

It executes when a broadcast has been re-scheduled.

Example Code

<?phpadd_hook('RescheduleBroadcast',1, function($vars) {	// Your code here});

StartBroadcast

It executes when a broadcast is started.

Example Code

<?phpadd_hook('StartBroadcast',1, function($vars) {	// Your code here});

PauseBroadcast

It executes when a broadcast is paused.

Example Code

<?phpadd_hook('PauseBroadcast',1, function($vars) {	// Your code here});

SystemPauseBroadcast

It executes when a broadcast is system-paused.

Example Code

<?phpadd_hook('SystemPauseBroadcast',1, function($vars) {	// Your code here});

CompleteBroadcast

It executes when a broadcast is completed.

Example Code

<?phpadd_hook('CompleteBroadcast',1, function($vars) {	// Your code here});

ResumeBroadcast

It executes when a broadcast is resumed.

Example Code

<?phpadd_hook('ResumeBroadcast',1, function($vars) {	// Your code here});

DeleteScheduledBroadcast

It executes when a scheduled broadcast is deleted.

Example Code

<?phpadd_hook('DeleteScheduledBroadcast',1, function($vars) {	// Your code here});

AddTrigger

It executes when a trigger is added.

Example Code

<?phpadd_hook('AddTrigger',1, function($vars) {	// Your code here});

EditTrigger

It executes when a trigger is edited.

Example Code

<?phpadd_hook('EditTrigger',1, function($vars) {	// Your code here});

DeleteTrigger

It executes when a trigger is deleted.

Example Code

<?phpadd_hook('DeleteTrigger',1, function($vars) {	// Your code here});

ResortTriggers

It executes when the triggers are re-sorted.

Example Code

<?phpadd_hook('ResortTriggers',1, function($vars) {	// Your code here});

AddBounceAddress

It executes when a bounce address is added.

Example Code

<?phpadd_hook('AddBounceAddress',1, function($vars) {	// Your code here});

EditBounceAddress

It executes when a bounce address is edited.

Example Code

<?phpadd_hook('EditBounceAddress',1, function($vars) {	// Your code here});

DeleteBounceAddress

It executes when a bounce address is deleted.

Example Code

<?phpadd_hook('DeleteBounceAddress',1, function($vars) {	// Your code here});

AddBounceRule

It executes when a bounce rule is added.

Example Code

<?phpadd_hook('AddBounceRule',1, function($vars) {	// Your code here});

EditBounceRule

It executes when a bounce rule is edited.

Example Code

<?phpadd_hook('EditBounceRule',1, function($vars) {	// Your code here});

DeleteBounceRule

It executes when a bounce rule is deleted.

Example Code

<?phpadd_hook('DeleteBounceRule',1, function($vars) {	// Your code here});

ResortBounceRule

It executes when the bounce rules are re-sorted.

Example Code

<?phpadd_hook('ResortBounceRule',1, function($vars) {	// Your code here});

AddSendingDomain

It executes when a sending domain is added.

Example Code

<?phpadd_hook('AddSendingDomain',1, function($vars) {	// Your code here});

EditSendingDomain

It executes when a sending domain is edited.

Example Code

<?phpadd_hook('EditSendingDomain',1, function($vars) {	// Your code here});

DeleteSendingDomain

It executes when a sending domain is deleted.

Example Code

<?phpadd_hook('DeleteSendingDomain',1, function($vars) {	// Your code here});

SendingDomainDKIMPassed

Executes when a Sending Domain's DKIM is passed

Example Code

<?phpadd_hook('SendingDomainDKIMPassed',1, function($vars) {    // Your code here});

SendingDomainTrackingPassed

Executes when a Sending Domain's Tracking is passed

Example Code

<?phpadd_hook('SendingDomainTrackingPassed',1, function($vars) {    // Your code here});


SendingDomainMXPassed 

Executes when a Sending Domain's MX is passed

Example Code

<?phpadd_hook('SendingDomainMXPassed',1, function($vars) {    // Your code here});


SendingDomainSPFPassed

Executes when a Sending Domain's SPF is passed

Example Code

<?phpadd_hook('SendingDomainSPFPassed',1, function($vars) {    // Your code here});

SendingDomainDKIMGenerted

Executes when a Sending Domain's DKIM is generated

Example Code

<?phpadd_hook('SendingDomainDKIMGenerted',1, function($vars) {	// Your code here});

SendingDomainVerified

Executes when the Sending Domain verification is successful

Example Code

<?phpadd_hook('SendingDomainVerified',1, function($vars) {	// Your code here});

SendingDomainSignOn

Executes when the Sending Domain's signing turns on

Example Code

<?phpadd_hook('SendingDomainSignOn',1, function($vars) {	// Your code here});

SendingDomainSignOff

Executes when the Sending Domain's signing turns off

Example Code

<?phpadd_hook('SendingDomainSignOff',1, function($vars) {	// Your code here});

AddSendingNode

It executes when a sending node is added.

Example Code

<?phpadd_hook('AddSendingNode',1, function($vars) {	// Your code here});

EditSendingNode

It executes when a sending node is edited.

Example Code

<?phpadd_hook('EditSendingNode',1, function($vars) {	// Your code here});

DeleteSendingNode

It executes when a sending node is deleted.

Example Code

<?phpadd_hook('DeleteSendingNode',1, function($vars) {	// Your code here});

AddWebForm

It executes when a web form is added.

Example Code

<?phpadd_hook('AddWebForm',1, function($vars) {	// Your code here});

EditWebForm

It executes when a web form is edited.

Example Code

<?phpadd_hook('EditWebForm',1, function($vars) {	// Your code here});

DeleteWebForm

It executes when a web form is deleted.

Example Code

<?phpadd_hook('DeleteWebForm',1, function($vars) {	// Your code here});

AddFeebackLoop

It executes when a feedback loop is added.

Example Code

<?phpadd_hook('AddFeebackLoop',1, function($vars) {	// Your code here});

EditFeebackLoop

It executes when a feedback loop is edited.

Example Code

<?phpadd_hook('EditFeebackLoop',1, function($vars) {	// Your code here});

DeleteFeebackLoop

It executes when a feedback loop is deleted.

Example Code

<?phpadd_hook('DeleteFeebackLoop',1, function($vars) {	// Your code here});

AddUser

It executes when a new user is added.

Example Code

<?phpadd_hook('AddUser',1, function($vars) {	// Your code here});

EditUser

It executes when a user is edited.

Example Code

<?phpadd_hook('EditUser',1, function($vars) {	// Your code here});

DeleteUser

It executes when a user is deleted.

Example Code

<?phpadd_hook('DeleteUser',1, function($vars) {	// Your code here});

AfterCron

It executes after the cronjob runs.

Example Code

<?phpadd_hook('AfterCron',1, function($vars) {	// Your code here});

Output Hooks

Output hooks render on the user interface and can be helpful to insert your own codes on the front-end.

HeadTop 

Add your code after the <head> tag

Example Code

<?phpadd_hook('HeadTop',1, function($vars) {	// Your code here});

HeadEnd 

Add your code before the </head> tag

Example Code

<?phpadd_hook('HeadEnd',1, function($vars) {	// Your code here});

BodyTop

Add your code after the <body> tag

Example Code

<?phpadd_hook('BodyTop',1, function($vars) {	// Your code here});

BodyEnd

Add your code before the </body> tag

Example Code

<?phpadd_hook('BodyEnd',1, function($vars) {	// Your code here});

PrimaryMenu

Add new menu items

Example Code

<?phpadd_hook('PrimaryMenu',1, function($vars) {   return '<li id="parent-1" class="parent-class kt-menu__item kt-menu__item--submenu" aria-haspopup="true" data-ktmenu-submenu-toggle="hover"><a href="javascript:;" class="kt-menu__link kt-menu__toggle"><span class="kt-menu__link-icon"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24px" height="24px" viewBox="0 0 24 24" version="1.1" class="kt-svg-icon"> <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> <rect id="bound" x="0" y="0" width="24" height="24"></rect> <path d="M10.5,5 L19.5,5 C20.3284271,5 21,5.67157288 21,6.5 C21,7.32842712 20.3284271,8 19.5,8 L10.5,8 C9.67157288,8 9,7.32842712 9,6.5 C9,5.67157288 9.67157288,5 10.5,5 Z M10.5,10 L19.5,10 C20.3284271,10 21,10.6715729 21,11.5 C21,12.3284271 20.3284271,13 19.5,13 L10.5,13 C9.67157288,13 9,12.3284271 9,11.5 C9,10.6715729 9.67157288,10 10.5,10 Z M10.5,15 L19.5,15 C20.3284271,15 21,15.6715729 21,16.5 C21,17.3284271 20.3284271,18 19.5,18 L10.5,18 C9.67157288,18 9,17.3284271 9,16.5 C9,15.6715729 9.67157288,15 10.5,15 Z" id="Combined-Shape" fill="#000000"></path> <path d="M5.5,8 C4.67157288,8 4,7.32842712 4,6.5 C4,5.67157288 4.67157288,5 5.5,5 C6.32842712,5 7,5.67157288 7,6.5 C7,7.32842712 6.32842712,8 5.5,8 Z M5.5,13 C4.67157288,13 4,12.3284271 4,11.5 C4,10.6715729 4.67157288,10 5.5,10 C6.32842712,10 7,10.6715729 7,11.5 C7,12.3284271 6.32842712,13 5.5,13 Z M5.5,18 C4.67157288,18 4,17.3284271 4,16.5 C4,15.6715729 4.67157288,15 5.5,15 C6.32842712,15 7,15.6715729 7,16.5 C7,17.3284271 6.32842712,18 5.5,18 Z" id="Combined-Shape" fill="#000000" opacity="0.3"></path> </g></svg></span><span class="kt-menu__link-text">Lists</span><i class="kt-menu__ver-arrow la la-angle-right"></i></a><div class="kt-menu__submenu " kt-hidden-height="200" style=""><span class="kt-menu__arrow"></span><ul class="kt-menu__subnav " id="s_1"><li id="child-10" class="child-class kt-menu__item  " aria-haspopup="true"><a href="http://mynewlink.com" class="kt-menu__link  "><i class="kt-menu__link-bullet kt-menu__link-bullet--dot"> <span></span></i><span class="kt-menu__link-text">Add Contact List</span></a></li><li id="child-11" class="child-class kt-menu__item  " aria-haspopup="true"><a href="http://mynewlink2.com" class="kt-menu__link  "><i class="kt-menu__link-bullet kt-menu__link-bullet--dot"> <span></span></i><span class="kt-menu__link-text">Contact Lists</span></a></li><li id="child-12" class="child-class kt-menu__item  " aria-haspopup="true"><a href="http://mynewlink3.com" class="kt-menu__link  "><i class="kt-menu__link-bullet kt-menu__link-bullet--dot"> <span></span></i><span class="kt-menu__link-text">Custom Fields</span></a></li><li id="child-13" class="child-class kt-menu__item  " aria-haspopup="true"><a href="http://mynewlink4.com" class="kt-menu__link  "><i class="kt-menu__link-bullet kt-menu__link-bullet--dot"> <span></span></i><span class="kt-menu__link-text">Segments</span></a></li><li id="child-14" class="child-class kt-menu__item  kt-menu__item--submenu" aria-haspopup="true"><a href="javascript:;" class="kt-menu__link  kt-menu__toggle"><i class="kt-menu__link-bullet kt-menu__link-bullet--dot"> <span></span></i><span class="kt-menu__link-text">Suppression</span><i class="kt-menu__ver-arrow la la-angle-right"></i></a><div class="kt-menu__submenu" kt-hidden-height="80"><span class="kt-menu__arrow"></span><ul id="c14" class="kt-menu__subnav"><li class="subchild-class kt-menu__item " aria-haspopup="true"><a href="http://mynewlink5.com" class="kt-menu__link "><i class="kt-menu__link-bullet kt-menu__link-bullet--line"> <span></span></i><span class="kt-menu__link-text">Email Suppression</span></a></li><li class="subchild-class kt-menu__item " aria-haspopup="true"><a href="http://mynewlink6.com" class="kt-menu__link "><i class="kt-menu__link-bullet kt-menu__link-bullet--line"> <span></span></i><span class="kt-menu__link-text">Domain Suppression</span></a></li><li class="subchild-class kt-menu__item " aria-haspopup="true"><a href="http://mynewlink7.com" class="kt-menu__link "><i class="kt-menu__link-bullet kt-menu__link-bullet--line"> <span></span></i><span class="kt-menu__link-text">IP Suppression</span></a></li></ul></div><script>  el = document.getElementById("c14");                                        el2 = document.getElementById("child-14");                                        var count = 0;                                            for (var i = 0; i < el.childNodes.length; i++) {                                            var node = el.childNodes[i];                                            if (node.nodeType == Node.ELEMENT_NODE) {                                                if(node.nodeName=="LI"){                                                count++;                                                break;                                                }                                            }                                        }                                        if(count==0)                                                el2.style.display = "none";                                    </script></li>                    <script>                        el_1 = document.getElementById("s_1");                        el_2 = document.getElementById("parent-1");                        var count_ = 0;                        for (var i_ = 0; i_ < el_1.childNodes.length; i++) {                            var node_ = el_1.childNodes[i_];                            if(node_.nodeName=="LI")                                count_++;                            break;                        }                        if(count_==0)                            el_2.style.display = "none";                    </script></ul></div></li>';});

TopNav

Add your code in the top navigation menu

Example Code

<?phpadd_hook('TopNav',1, function($vars) {	// Your code here});

Add your code in the breadcrumb navigation

Example Code

<?phpadd_hook('BreadcrumbNav',1, function($vars) { if(!empty($vars['route']) && $vars['route']=='list.index')	return '<div class="kt-subheader__main">			<div class="kt-subheader__breadcrumbs">				<a href="https://www.mynewlink.com" class="kt-subheader__breadcrumbs-link">Dashboard</a>				<span class="kt-subheader__breadcrumbs-separator"></span>				<a href="https://www.mynewlink2.com" class="kt-subheader__breadcrumbs-link">Lists</a>				<span class="kt-subheader__breadcrumbs-separator"></span>				<span class="kt-subheader__desc">All Listsqwegg</span>													</div>		</div>';});

AlertBar

Add your code in the alert bar below the breadcrumb

Example Code

<?phpadd_hook('AlertBar',1, function($vars) {	// Your code here});

TitleBar

Add your code in the top title/description bar

Example Code

<?phpadd_hook('TitleBar',1, function($vars) {   if(!empty($vars['route']) && $vars['route']=='list.index')    return '<div class="pagetitle" style="display: block;">    <h4 class="alert-heading">Contact Lists</h4><p>Contact lists page is where you view your created lists with multiple sorting options (default sorting is by creation date in descending order). You can view, edit and manage existing contact lists and groups, moreover perform additional actions e.g add a contact, import contacts, make a copy, export to CSV, split list, merge into another list, etc.</p>        </div>';});add_hook('TopNav',1, function($vars) {   });

Add your code in the footer of the application

Example Code

<?phpadd_hook('Footer',1, function($vars) {	// Your code here});

ContentEnd

Add your code in the main content area at the end

Example Code

<?phpadd_hook('ContentEnd',1, function($vars) {	// Your code here});

BroadcastScheduleFinalCheck

Add your code at the last on the campaign schedule page

Example Code

<?phpadd_hook('BroadcastScheduleFinalCheck',1, function($vars) {	// Your code here});

MiniMenu

Add your code in the top mini menu at the right corner

Example Code

<?phpadd_hook('MiniMenu',1, function($vars) {	// Your code here});

addPageHtml

Add your code anywhere on the page

Example Code

<?phpadd_hook('addPageHtml',1, function($vars) {	// Your code here});