Guide to Standardized Hooks - Function Hooks

Introduction

Function hook scripts run automatically, after a specific cPanel API function. You can associate each hook with a single cPanel API 1 or cPanel API 2 function. Because function hooks run after an API function, they cannot block or modify events on the server. 

Warning:

This hook method is deprecated. To convert function hooks to use the Standardized Hooks system, use the API::Module::functionCpanel event in your Hook Action Code.

Basic usage

To create a function hook, perform the following steps:

  1. Write a function hook script.
  2. Store the function hook script in the /usr/local/cpanel/hooks/module/function/ directory, where module is the cPanel API 1 or cPanel API 2 module name, and function is the function name.
    • For example, store a script that runs after the  Email::addpop  function in the  /usr/local/cpanel/hooks/Email/addpop/ directory.
  3. Run the  /usr/local/cpanel/bin/register_hooks script to register the function hook.
    • Run this script every time that you add a new hook script or modify an existing hook script.
    • This script  cannot  register scripts that have incorrect file permissions.

Scripts

You can write function hook scripts in any programming language.

Warning:

  • Function hook scripts run as the  root  user.
  • You must set script file permissions to 0700.
  • Function hook scripts cannot produce output. You must silence any header content that your script's interpreter generates.

The system sends two types of data to STDIN whenever it runs a function hook script:

  1. The input parameters from the associated function call, in <cpanelevent> tags.
  2. A hash of user data, in <CPDATA> tags. This data includes the contents of the user's file in the /var/cpanel/users/ directory.
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

The cPanel Interface

For  cPanel  &  WHM  version  58 Overview The cPanel interface is...

User Preferences

For cPanel & WHM version 58 Overview This document outlines how to access your cPanel...

Manage External Authentications

For cPanel & WHM version 58 Overview Manage credentials Additional documentation...

What is cPanelID?

In This Article:  Overview ServicesHow to get a cPanelID cPanelID External...

Guide to cPanel Interface Customization - cPanel Style Development

Introduction You can develop custom styles that modify the appearance of the cPanel interface....