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.

create an api whm object.

Discussion in 'cPanel Developers' started by Guda, May 22, 2015.

  1. Guda

    Guda Member
    PartnerNOC

    Joined:
    Aug 16, 2001
    Messages:
    20
    Likes Received:
    1
    Trophy Points:
    1
    Trying to create an whm api object in a custom module. Is this possible, this method would actually be used for a Account::Create hook rollback. If the hook fails I want to terminate the newly activated account.

    Looking to do something along the lines of.

    package Cpanel::MyModule;

    use Cpanel ();

    sub method {
    my ($params) = @_;

    my $cpanel = Cpanel->new;
    return $cpanel->api(method => 'terminateaccnt' );

    }

    1;
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,694
    Likes Received:
    654
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    The following document is a good place to get started if you want to use standardized hooks:

    Guide to Standardized Hooks

    You can implement a post account creation hook that terminates an account if certain criteria is not met.

    Thank you.
     
  3. Guda

    Guda Member
    PartnerNOC

    Joined:
    Aug 16, 2001
    Messages:
    20
    Likes Received:
    1
    Trophy Points:
    1
    lol, I know where the docs are.... I also know that I can implement a post account creation hook that terminates an account if certain criteria is not met. I mean geez... thats what got me here int he first place. You didnt answer any part of my question just lol.. I dont even know what kind of response it was you sent.. just.. totally dodging the question.

    anyways.. so again..

    1. I create an account.
    2. post account hook fails.
    3. i want to now terminate the account that was created prior to the account::create hook failure.

    according to your docs you can do this by defining a rollback action. So what exactly triggers the rollback definition to execute? return value from the hook? if so, then what kind of return value? do you have examples?

    Also, if I am creating a custom module to be put in in /usr/local/cpanel/Cpanel, what code would i use to create a dispatch object that I can use to access the api.
     
    cadomagenge likes this.
  4. Guda

    Guda Member
    PartnerNOC

    Joined:
    Aug 16, 2001
    Messages:
    20
    Likes Received:
    1
    Trophy Points:
    1
    this is resolved.
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,694
    Likes Received:
    654
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Would you mind sharing the resolution or letting us know the ticket number so we can update this thread for other users who encounter a similar issue?

    Thank you.
     
Loading...

Share This Page