Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Introduction

Excerpt
Hookable events set the action that triggers a hook, and whether the hook triggers before or after the event.

 Within any cPanel & WHM event (for example, an API call or binary process), the code contains the following phases:

  1. Preparation — The preparation of variables and the environment.

  2. Execution — The execution of specific operations.
  3. Rendering — The rendering of the operation's results via HTTP content headers and body.

cPanel & WHM events run routines before (pre) or after (post) the execution phase. 

Note
titleNote:

Most pre events can signal a failure that skips the execution phase of the event entirely. The rendering phase uses this signal as if the failure occurred natively, before execution.

Hookable events

The Standardized Hooks system uses the following categories for hookable events:

  • ConvertAddon — 
    Excerpt Include
    Guide to Standardized Hooks - ConvertAddon Functions
    Guide to Standardized Hooks - ConvertAddon Functions
    nopaneltrue
  • Cpanel — 
    Excerpt Include
    Guide to Standardized Hooks - Cpanel Functions
    Guide to Standardized Hooks - Cpanel Functions
    nopaneltrue
  • PkgAcct — 
    Excerpt Include
    Guide to Standardized Hooks - PkgAcct Functions
    Guide to Standardized Hooks - PkgAcct Functions
    nopaneltrue
  • Passwd — 
    Excerpt Include
    Guide to Standardized Hooks - Passwd Functions
    Guide to Standardized Hooks - Passwd Functions
    nopaneltrue
  • RPM::Versions — 
    Excerpt Include
    DD:Guide to Standardized Hooks - RPM::Versions Functions
    DD:Guide to Standardized Hooks - RPM::Versions Functions
    nopaneltrue
  • Stats — 
    Excerpt Include
    Guide to Standardized Hooks - Stats Functions
    Guide to Standardized Hooks - Stats Functions
    nopaneltrue
  • System — 
    Excerpt Include
    Guide to Standardized Hooks - System Functions
    Guide to Standardized Hooks - System Functions
    nopaneltrue
  • Whostmgr — 
    Excerpt Include
    Guide to Standardized Hooks - Whostmgr Functions
    Guide to Standardized Hooks - Whostmgr Functions
    nopaneltrue
Warning
titleImportant:

Advanced users can define additional hookable events in their custom modules.

Hookable event attributes

All hookable events are comprised of three main attributes:

  1. category — The event's logical grouping within cPanel & WHM.
  2. event — The event that cPanel & WHM performs.
  3. stage — The location of the trigger that runs the hook action code, relative to the event.

Some hookable events may include additional attributes:

  • blocking — Whether a returned failure from the hook action code prevents the event's execution. Only specific  pre -stage events can block.
  • escalateprivs — Whether the hookable event can escalate privileges before the hook action code runs. (Scripts only.)
  • Action Code Run As — The system user that owns the process that executes the hook action code.
Note
titleNote

These additional attributes are implicit implementation details that relate to the cPanel & WHM code that dispatches the hookable event.

If the blocking and escalateprivs attributes are present for a given event, the hook action code can use the describe method to define the rollback and escalateprivs attributes for registration.