After every important action taken in HostBill its engine report Event. PHP code executed when event occurs are called Hooks.
When Event occur, HostBill executes related Hooks code and passes event data as variable to them.

Note: hooks does not require any configuration files, or special classes / structures.
If you’d like to incorporate hooks into Plugin/Provisioning/Domain module follow guides mentioned in Module Events article

Hooks location

Hooks are located inside includes/extend/hooks directory. Each HostBill installation is shipped with sample hook files.

Adding hooks

  1. Go to includes/extend/hooks directory and remove .sample extension from hook you’d like to use
  2. Edit related hook file i.e. after_accountcreate_01.php place php code there that should be executed when event occur

Using multiple hooks

You can use multiple files for each event, to add another hook create file in hooks directory with following naming convention:
{event_name}_{PRIORITY}.php

Where:
{event_name} is one of events you wish to hook, from list below
{PRIORITY} is number, telling HostBill in which order execute files. HostBill executes hook files from lowest number up.

File: after_accountcreate_01.php

<?php
//each sample hook file contains available variable explained in comment inside
echo "New account has been created!";
exit;
?>

Events in HostBill

Events

after_accountchangepackage

Account-related module (for ex. cPanel) successfully changed package on server

after_accountchangepassword

Account-related module (for ex. cPanel) successfully changed password of account

after_accountcreate

Account-related module (for ex. cPanel) successfully created account

after_accountformsupgrade

Client ordered field upgrade/downgrade and it has changed by accepting order (auto or manual)

after_accountsuspend

Account-related module (for ex. cPanel) successfully suspended account ID=$details

after_accountterminate

Account-related module (for ex. cPanel) successfully terminated account

after_accountunsuspend

Account-related module (for ex. cPanel) successfully unsuspended account ID=$details

after_addoncreate

Addon was activated

after_addonsuspend

Addon was suspended

after_addonterminate

Addon was terminated

after_cancellationrequest

Client posted cancelation request for account

after_clientadded

New client has been registered in database,

after_clientchangepassword

Client just changed his password

after_clientdelete

Client has just been deleted from HostBill database

after_clientedit

Client details has been updated in database

after_clientlogin

Client with ID=$details just logged in

after_clientlogout

Client with ID=$details just logged out

after_cronrun

This event is invoked every 5 minutes with cron run

after_domainregister

HostBill succesfully registered domain $details = array(‘id’=>RELATED DOMAIN ID IN HOSTBILL, ‘name’=>DOMAIN NAME);

after_domainrenew

HostBill succesfully renewed domain $details = array(‘id’=>RELATED DOMAIN ID IN HOSTBILL, ‘name’=>DOMAIN NAME);

after_domainsave

Domain details has been changed

after_domaintransfer

HostBill succesfully transfered domain $details = array(‘id’=>RELATED DOMAIN ID IN HOSTBILL, ‘name’=>DOMAIN NAME);

after_estimatecreate

New estimate has just been created with ID=$details

after_invoicecreate

New invoice has just been created with ID=$details This event is called after every items saved for the invoice. So if you will get this event you will be sure that invoice has been successfully created.

after_invoicefullpaid

Invoice has been fully paid

after_invoicelatefee

Late fee has been applied to invoice ID=$invoice_id

after_invoicepartialpayment

Partial payment to invoice has been applied NOTE: Applying partial payment doesnt mean that invoice was fully paid.

after_invoiceupdatetotal

Invoice total amount has been changed (new item has been added/items edited etc)

after_ordercreate

New order has been placed

after_refund

Refund from admin interface was successfull

after_ticketadminreply

Administrator has just posted reply to a ticket $details = array(‘id’=>REPLY ID, ‘ticket_id’=>RELATED TICKET ID, ticket_number’=>RELATED TICKET NUMBER, ‘replier_id’=>REPLIER ID (IF ANY), ‘name’=>REPLIER NAME, ’email’=>REPLIER EMAIL, ‘body’=>REPLY MESSAGE BODY, ‘type’=>REPLIER TYPE (Admin or Client), ‘date’=>REPLY DATE)

after_ticketclientreply

Client has just posted reply to a ticket $details = array(‘id’=>REPLY ID, ‘ticket_id’=>RELATED TICKET ID, ‘replier_id’=>REPLIER ID (IF ANY), ‘name’=>REPLIER NAME, ’email’=>REPLIER EMAIL, ‘body’=>REPLY MESSAGE BODY, ‘type’=>REPLIER TYPE (Admin or Client), ‘date’=>REPLY DATE)

after_ticketdelete

Administrator deleted ticket $details =array(‘id’=>RELATED TICKET ID IN HOSTBILL DB, ‘ticket_number’=>RELATED TICKET NUMBER, ‘acc_hash’=>REMOTE ACCESS HASH FOR NON_REGISTERED VIEWS, ‘dept_id’=>RELATED DEPARTMENT ID, ‘client_id’=>RELATED CLIENT ID (IF ANY), ‘name’=>SUBMITTER NAME, ’email’=>SUBMITTER EMAIL, ‘subject’=>TICKET SUBJECT, ‘body’=>TICKET BODY, ‘status’=>TICKET STATUS)

after_ticketopen

New support ticket has just been created $details =array(‘ticket_id’=>RELATED TICKET ID IN HOSTBILL DB, ‘ticket_number’=>RELATED TICKET NUMBER, ‘acc_hash’=>REMOTE ACCESS HASH FOR NON_REGISTERED VIEWS, ‘dept_id’=>RELATED DEPARTMENT ID, ‘client_id’=>RELATED CLIENT ID (IF ANY), ‘name’=>SUBMITTER NAME, ’email’=>SUBMITTER EMAIL, ‘subject’=>TICKET SUBJECT, ‘body’=>TICKET BODY, ‘status’=>TICKET STATUS)

after_transactionadd

Transaction has been sucessfully stored in HostBill database

before_clientlogin

Client is atempting to log in with:
$details[’email’] – email address provided in client login form. Note: Email is just arbitrary, you can modify your clientarea “email” label in login form and have client provide his username to authentincate with

$details[‘password’] – password client proivied in client login form

You can use this hook to authenticate client against external database/auth service.
To do so, after successfull auth, simply return client id that HostBill should log in.
ie. return 10; //login client with id=10 (hb_client_access.id=10).

If client have provided wrong credentials – dont return any value – this way HostBill
will fall-back to its internal authentication methods.

before_clientadded

Client posted sign-up form, but he is not registered yet/ This event is called BEFORE HostBill validates/sanitizes input

before_clientdelete

Client has just been deleted from HostBill database

before_displayadminfooter

This event is called when adminarea footer is rendered – use this to inject your custom scripts/meta tags etc.

before_displayadminheader

This event is called when adminarea header is rendered – use this to inject your custom scripts/meta tags etc.

before_displayuserfooter

This event is called when clientarea footer is rendered – use this to inject your custom scripts/meta tags etc.

before_displayuserheader

This event is called when clientarea header is rendered – use this to inject your custom scripts/meta tags etc.

before_domainregister

HostBill is about to take an attempt to register domain $details = array(‘id’=>RELATED DOMAIN ID IN HOSTBILL, ‘name’=>DOMAIN NAME);