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::function
Cpanel
event in your Hook Action Code.
Basic usage
To create a function hook, perform the following steps:
- Write a function hook script.
- Store the function hook script in the
/usr/local/cpanel/hooks/module/function/
directory, wheremodule
is the cPanel API 1 or cPanel API 2 module name, andfunction
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.
- For example, store a script that runs after the
- 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:
- The input parameters from the associated function call, in
<cpanelevent>
tags. - A hash of user data, in
<CPDATA>
tags. This data includes the contents of the user's file in the/var/cpanel/users/
directory.