• Home
  • Create Plugins
  • Contact Us
  • Demo
    Installation & MaintenancePersonalizationSettingsClient ManagementInvoices & PaymentsProjects & TasksTeam & CollaborationProductivity ToolsSales & ServicesPluginsFAQChange logs
  1. Docs
  2. Plugins

Available functions for plugins

Call this functions in your My_Plugin folder/index.php file.

  • Register installation hook. When the plugin is about to install, this function will be triggered. Execute required sql queries or purchase code validation here.
register_installation_hook("My_Plugin", function ($item_purchase_code) {
  //validate purchase code if you wish
  if (!validate_purchase_code($item_purchase_code)) {
      echo json_encode(array("success" => false, 'message' => "Invalid purchase code"));
      exit();
  }

//run necessary sql queries 
$db = db_connect('default');
$db_prefix = get_db_prefix();
$db->query("SET sql_mode = ''");
$db->query("CREATE TABLE IF NOT EXISTS `" . $db_prefix . "plugin_table` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `title` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
    `deleted` tinyint(1) NOT NULL DEFAULT '0',
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;");
});


  • Register uninstallation hook. When the plugin is about to uninstall, this function will be triggered.
register_uninstallation_hook("My_Plugin", function () {
  //run something
});


  • Register activation hook. When the plugin is about to activate, this function will be triggered.
register_activation_hook("My_Plugin", function () {
  //run something
});


  • Register deactivation hook. When the plugin is about to deactivate, this function will be triggered.
register_deactivation_hook("My_Plugin", function () {
  //run something
});


  • Register update hook. Provide information to update your plugin. Please note that, if your updates has any version comparability, check that while updating.
register_update_hook("My_Plugin", function () {
  //show necessary information to update this plugin in the modal
});


  • Register data insert hook.
register_data_insert_hook(function ($data) {
  //some data has been inserted

  /* 
  the $data array has 3 items
  id => inserted id
  table => associated table with db prefix
  table_without_prefix => associated table without db prefix
  data => inserted data array
  */
});


  • Register data update hook.
register_data_update_hook(function ($data) {
  //some data has been updated

  /* 
  the $data array has 3 items
  id => updated id
  table => associated table with db prefix
  table_without_prefix => associated table without db prefix
  */
});


  • Register data delete hook.
register_data_delete_hook(function ($data) {
  //some data has been deleted
  /* 
  the $data array has 2 items
  id => deleted id
  table => associated table with db prefix
  table_without_prefix => associated table without db prefix
  */
});     


Was this article helpful? Yes No
How can we improve this article?
© 2026 Fairsketch
Home 3rd Party Plugins Get Support Buy Now

Delete?

Are you sure? You won't be able to undo this action!
To do