Guide to Standardized Hooks - Cpanel Functions

Introduction

The Cpanel category creates hookable events for cPanel API 1, cPanel API 2, or UAPI functions. 

API::Module::function


Cpanel events all use the API::Module::function naming format, where:

  • API is the API that calls the hook point. 
    • Use Api1 for cPanel API 1 functions, Api2 for cPanel API 2 functions, or UAPI for UAPI functions.
    • This value is case-sensitive.
  • Module is the function's module name (for example, StatsBar).
  • function is the function name (for example, stat).

Available Stages:

  • pre — Hook action code runs before the event.
  • post — Hook actions code runs after the event.

post stage call failure

If an API call fails to execute, whether the post-stage hook runs depends on which API that you use.

  • API1 function post-hooks always run, regardless of whether the call succeeds.
  • API2 function post-hooks always run, but they also include data about whether the API function succeeds. 

    • In your post-hook code, the data->{'output'}{'result'} section displays the call's status. For example:

      1
      2
      3
      4
      5
      6
      "output" : [
         {
            "reason" : "File not found.\n",
            "result" : 0
         }
      ]

       

  • UAPI post-hooks do not run if the API call fails.

Action Code Runs As:

The cPanel user.

Important:

Remote API calls that proxy to cPanel's API and cPanel API calls that are performed as a reseller in the cPanel interface will affect this user and not the authenticated user. 

Blocking Attribute:

Escalate Privileges Attribute:


Output parameters

Note:

The chosen stage determines the event's output. Select the appropriate tab to view output parameters for that stage. 

Pre

 Parameter 

Type

Description

Possible values

Example

args

 See description. 

  • For cPanel API 1 functions, an array reference with elements for each of the function's parameters.
  • For cPanel API 2 functions, a hash reference with key=valuepairs for each of the function's parameters. 

 See the desired function's documentation. 

 

output

string

A variable reference, which cPanel & WHM is likely to overwrite during processing.

  • A variable reference.
  • An undefined value.

Important:

Expect an undefined value. 

undef

user

string

The cPanel user's username.

A valid cPanel username on the server.

 username 

 
Post

Parameter

Type

Description

Possible values

Example

user

string

The user for whom the password will change.

A valid username on the server.

username

 new_password 

 string 

The user's new password.

A secure password.

12345luggage

rawout

string

The event's raw output.

A string value.

This is raw output.

applist

string

 A list of applications for which the password changed. 

 A list of one or more application names. 

 application1,applicat 

 

  • 5 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....