Sendroid Ultimate Event Hook Tutorial
Introduction
Sendroid Ultimate consist of over 50 different event hooks, which can be used to inject a feature to an even or entirely alter the way Sendroid Ultimate handles such event.
With the event hook system, one can add a new feature, modify Sendroid Ultimate behavior or even remove a feature from Sendroid Ultimate without altering the original source code of the script
Creating An Event Hook
Sendroid Ultimate event hook files are located in \system\eventhooks folder. Any event hook file located outside of this folder may not be recognized by Sendroid Ultimate.
All variables available for use with each event are stored in a session named "EventVals", and can be accessed from $_SESSION['EventVals']
First, create a new php file, giving it a unique name (e.g. sample1234.php)
Next, create a function with a unique name to hold your main custom event logics or features. It is important to give this function a very unique or random name, not easy to imitate (e.g. my_the864histh37hg_functionname() {}) as duplicate function names will result in an internal server error, which will definitly affect Sendroid Ultimate.
‹?php function notify_admin_uye8843(){ }
Next, write all your core codes within this function. You can also create other classes or functions within the hook file and call then from your main function if required.
‹?php function notify_admin_uye8843(){ $vars = $_SESSION['EventVals']; $id = $vars['id']; $first_name = $vars['first_name']; $last_name = $vars['last_name']; $email = $vars['email']; $password = $vars['password']; //echo 'A new user just signed up with email '.$email; }
Finally, attach your main function to the desired event so Sendroid Ultimate can call your function each time the event iruns
‹?php global $hooks; $hooks->add_action('CustomerCreate','notify_admin_uye8843'); function notify_admin_uye8843(){ $vars = $_SESSION['EventVals']; $id = $vars['id']; $first_name = $vars['first_name']; $last_name = $vars['last_name']; $email = $vars['email']; $password = $vars['password']; //echo 'A new user just signed up with email '.$email; }
Available Events
General Events
Event | Description | Event Variables |
OnAjaxRequests | Called each time a request is made to Sendroid Ultimate ajax requesthandler (yoururl/API) | - |
HeaderEvent | Called at the top of every page, bofore any HTML output | - |
CustomFooterEvents | Called after Sendroid Ultimate footer HTML codes | - |
CustomJavaScripts | Called before the closing <body> tag. Can be used to inject custom javascript code | - |
HourCronEvent | Called everytime the Hour Cron job executes | - |
MinuteCronEvent | Called everytime the Munite Cron job executes | - |
Menu Events
Event | Description | Event Variables |
AddMenuAccount | Called on the user account menu. Can be used to inject a custom menu item under the user account (righ-side) menu | - |
AddMenuMainBefore | Called before any main menu item is loaded. Can be used to insert a menu item above all other menu items | - |
AddMenuMainCompose | Called under the Composer menu. Can be used to add a new menu item under the Composer menu | - |
AddMenuMainContact | Called under the Contacts menbu. Can be used to add a new menu item under the Contacts menu | - |
AddMenuMainExtras | Called under the Extras menu. Can be used to add new menu item under the Extras menu | - |
AddMenuMainAfterExtra | Called after the Extras main menu item. Can be used to add a new main menu item after the Extras menu | - |
AddMenuMainTools | Called under the Tools menu. Can be used to add a new menu item under the Tools menu | - |
AddMenuMainSetting | Called under the Settings menu. Can be used to add new menu item under the Settings menu | - |
AddMenuMainAfter | Called just before the Logout menu item. Can be used to add a new menu item just above the Logout menu. | - |
AddMenuMainReseller | Called under the Reseller menu. Can be used to add new menu item under the Reseller menu | - |
Account & Authentication Events
Event | Description | Event Variables |
UserLogin | Called everytime a user logs into Sendroid Ultimate | id: The ID of the user |
PasswordChange | Called when a user changes or requests a new login password | id: The ID of the user email: The email address of the user password: The new password of the user first_name: The first name of the user last_name: The last name of the user |
CustomerCreate | Called when a new Customer/Reseller is created | id: The ID of the user |
Messaging Events
Event | Description | Event Variables |
BeforeSendMessage | Called just before a message is queued | sender_id: The message sender ID to: The message recipient(s) message: The message content customer_id: The ID of the customer type: The message type (sms, mms, whatsapp, unicode or flash) media: The media file URL if any |
BeforeProcessMessage | Called just before a queued message is processed or submitted to gateway | id: The unique database ID of the message sender_id: The message sender ID to: The message recipient message: The message content customer_id: The ID of the customer type: The message type (sms, mms, whatsapp, unicode or flash) media: The media file URL if any |
AfterMessageProcess | Called just after a queued message is processed or submitted to gateway | id: The unique database ID of the message sender_id: The message sender ID to: The message recipient message: The message content customer_id: The ID of the customer type: The message type (sms, mms, whatsapp, unicode or flash) media: The media file URL if any |
OnIncomingMessage | Called each time a new incoming SMS is received in Sendroid Ultimate. Can be used to create custom inbound message event | customer: Customer ID of the message owner from: The sender's number to: The number or shortcode that received the message message: The received message content |
CustomIncomingMessage | Called at the end of Sendroid Ultimate Inbound Message Callback script. Can be used to add a custom inbound message gateway or callback action | - |
Other Events
Event | Description | Event Variables |
OrderCreate | Called when ever a transaction or order is initiated or created | reference: The transaction reference credits: The quantity of credit amount: The amount billed in the customer's currency customer_id: The ID of the customer method: The payment method used description: The transaction description |
ShortcodePurchase | Called eachtime a customer buys a shortcode or number | customer_id: The ID of the customer shortcode: The shortcode or number purchased duration: The subscription period |
SenderIDCreate | Called when a new Sender ID is created | customer_id: The ID of the customer sender_id: The sender ID added type: The sender ID type |
TicketCreate | Called each time a support ticket is created or updated | subject: The ticket subject customer_name: The customer's name customer_email: The customer's email customer_id: The ID of the customer status: The status of the ticket |
ShortcodeCreate | Called when a new shortcode or number is created | shortcode: The shortcode or number created type: List shortcode supported message types |
OnPhoneVerify | Called when a customer successfully verifies account phone number | customer_id: The ID of the customer |
OrderComplete | Called when a transaction or order is completed or processed | reference: The transaction reference credits: The quantity of credit amount: The amount billed in the customer's currency customer_id: The ID of the customer method: The payment method used description: The transcation decsription |
OnAPICall | Called at the top of the HTTP API script. Can be used add a custom feature to sendroid ultimate API | - |
AfterAPICall | Called at the end of the HTTP API script. Can be used add a custom feature to sendroid ultimate API | - |
PreDashboardEvents | Called at the top of the dashboard UI. Can be used to add custom dashboard features | - |
PostDashboardEvents | Called at the end of the dashboard UI. Can be used to add custom dashboard features | - |
OnCiustomerView | Called when a customer's profile is viewed. Can be used to add custom information on the customer view page | customer_id: The ID of the current list customer |
CustoerTableAction | Called on each customer list item. Can be used to add a custom action to the customer list table | customer_id: The ID of the current customer list item |
OnAPIView | Called on the Sendroid Ultimate API Reference page. Can be used to add custom specifications or information on the API reference page | - |
BeforeSMSCompose | Called at the top of the SMS composer page. Can be used to injesct custom actions or feature on the SMS composer page | message_type: The message type being composed user_id: The logged-in user ID |
InSMSComposeForm | Called within the SMS compose form, just above the message form field. Can be used to inject a custom form feature into the message compose page | message_type: The message type being composed user_id: The logged-in user ID |
AfterSMSCompose | Called at the end of the SMS composer page. Can be used to injesct custom actions or feature on the SMS composer page | message_type: The message type being composed user_id: The logged-in user ID |
TransactionTableAction | Called on each transaction list item. Can be used to add a custom action to the transcation list table | reference: The Reference of the current transaction list item |
PhonebookTableAction | Called on each phonebook list item. Can be used to add a custom action to the phonebook list table | id: The ID of the current phonebook list item |
MarketingListTableAction | Called on each marketing list item. Can be used to add a custom action to the marketing list table | id: The ID of the current marketing list item |
CustomerOrderSummary | Called on the Order Summary side-bar on customer order page | id: The ID of the logged-in customer |
LoginHeaderAction | Called at the top of the login and sign-up page. Can be used to injesct custom actions or feature on the login page | - |
LoginFooterAction | Called at the end of the login and sign-up page. Can be used to injesct custom actions or feature on the login page | - |