The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Trigger action on CPanel account update

Discussion in 'cPanel Developers' started by dosinformatica, Dec 15, 2010.

  1. dosinformatica

    dosinformatica Registered

    Oct 5, 2010
    Likes Received:
    Trophy Points:
    I was wondering if there is a way to trigger a script whenever a user update anything in his CPanel account - for example add an email, add a forward, add an addon domain, ecc.
    I wrote a script that fix some issue when using WHM in a natted environment, ... I'd like to have it triggered whenever a user perform any kind of modification to its CPanel account

    I hope somebody know the answer to this question

    thank you
  2. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Dec 17, 2009
    Likes Received:
    Trophy Points:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hi dosinformatica,

    The best way would be to create a Custom Event Handler. Essentially, anytime a cPanel API action is called, the calling arguments will be past to the custom event handler before and after cPanel processes the action. This gives you the ability to preprocess all events (and optionally terminate the request early base on your criteria) or you can do something afterwards, like update system settings or log some information, or fire off a script. Custom event handlers are just one big Perl script (well, you can subclass or bring in whatever you IS Perl ;) ). Since its just one script that cPanel is exchanging information with, you'll have to put in the necessary filter or "if/else" logic to catch which API calls you're interested in.

    Function Hook scripts are another option. You make a function hooks when you need to trigger based on one API call; there's a direct one-to-one relationship: for each API, you'll need a separte function hook.

    Function hooks are nice because they are spawned as their own process. Custom event handlers are executed inline with the cPanel code (which could slow cPanel requests down). Also Function hooks are language agnostic (well, anything that a shell could execute: PHP, Perl, Bash, Ruby, Python, etc), custom event handlers must be written in Perl.

    Try searching on the forums for more information and checkout those links. I'd be happy to answer any specific question.


Share This Page