Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

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.

whostmgr hooks metadata

Discussion in 'cPanel Developers' started by Mostafa Hussein, Mar 4, 2017.

Tags:
  1. Mostafa Hussein

    Joined:
    Sep 27, 2015
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Egypt
    cPanel Access Level:
    Root Administrator
    In Cpanel Hooks i can get the full json payload using stdin. and this includes information about the event its category and stage and name for example:

    Code:
    u'context': {u'category': u'Cpanel', u'stage': u'post', u'event': u'Api2::SubDomain::addsubdomain', u'point': u'main', u'escalateprivs': 1}}
    Is there a way to do the same in Whostmgr hooks specifically with the account operations like create / modify / terminate / restore ? I have seen similar output in this thread but with a different event. Is this something enabled with specific events only ?

    In Whostmgr hook the only way to get the value by get the argv result unlike Cpanel hook which i can get its result using stdin
     
  2. Mostafa Hussein

    Joined:
    Sep 27, 2015
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Egypt
    cPanel Access Level:
    Root Administrator
    I made it work thanks
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,427
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    I'm happy to see you were able to obtain the data. Could you let us know the specific solution you found?

    Thank you.
     
  4. Mostafa Hussein

    Joined:
    Sep 27, 2015
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Egypt
    cPanel Access Level:
    Root Administrator
    The hook wont be able to receive the data as input unless you made it listen to the correct event so instead of listening to `createacct` which from whmapi1 you need to listen to `Accounts::Create` otherwise the hook will receive the data as parameters which has a different json structure.

    So the question might be why the Hook accepts any kind of event even if its not correct ? and How can I get the correct event name? As you can see in the link mentioned in my question Kenneth Power said that the correct event is Accounts::SiteIP::set and not setsiteip. and both worked same as my case with createacct and Accounts::Create but each one of them returns a different json structure.
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,427
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    You can find the corresponding API function by turning on debug mode under the "Development" tab in "WHM >> Tweak Settings", performing the specific action you want to hook into via cPanel or WHM, and then watching the output from /usr/local/cpanel/logs/error_log. Here's an example of the output you will see when creating an account:

    Code:
    [2017-03-13 12:02:11 -0500] info [whostmgr5] ---debug_hooks---
    [2017-03-13 12:02:11 -0500] info [whostmgr5]             msg: No hooks found for traversed context
    [2017-03-13 12:02:11 -0500] info [whostmgr5]         context: Whostmgr::Accounts::Create
    [2017-03-13 12:02:11 -0500] info [whostmgr5]           stage: pre
    [2017-03-13 12:02:12 -0500] info [whostmgr5] ---debug_hooks---
    [2017-03-13 12:02:12 -0500] info [whostmgr5]             msg: No hooks found for traversed context
    [2017-03-13 12:02:12 -0500] info [whostmgr5]         context: Whostmgr::Accounts::Create
    [2017-03-13 12:02:12 -0500] info [whostmgr5]           stage: post
    Thus, in this case it shows that you should use "Accounts::Create".

    Thank you.
     
Loading...

Share This Page