# Hooks

Hooks are user-defined PHP code blocks executed by HostBill before or after certain events.

# Simple use

Easiest way of adding hook handles is by creating php file named as hook with in includes/extend/hooks dir.

Code in your hook file will be executed when related event occurs.

Example: includes/extend/hooks/after_clientlogin_01.php

echo "Client with id: ".$details." just logged in";

# Advanced use

Advanced hook php files:

  • are also stored in the includes/extends/hooks dir
  • their names can't contain underscores
  • are executed on each HostBill front/back visit
  • hook handles must added explicitly
  • one file can contain multiple handles for different events
  • hook handles can work with event modifiers

Example: includes/extend/hooks/mycustomhook.php

HBEventManager::handle('after_clientlogin',function($details) {
   echo "Client with id: ".$details." just logged in";

# Hooks in modules

Modules built with HostBill SDK can also easily utilize hooks.

Example: includes/modules/Other/custommodule/class.custommodule.php


class CustomModule extends OtherModule implements Observer {

    public function after_clientlogin($details) {
        echo "Client with id: ".$details." just logged in";


# Webhooks

All HostBill version are shipped with Webhooks (opens new window) module allowing to notify external systems on HostBill events

Last Updated: 3/23/2023, 6:02:30 PM