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.

How to add scripts before a user is created in WHM

Discussion in 'cPanel Developers' started by louisliu, Oct 2, 2010.

  1. louisliu

    louisliu Registered

    Joined:
    Oct 1, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    I want to add some scripts when i create a new account in WHM:
    Once all data is submitted in that page, the new user is created and the required changes are made.
    The processing script should be altered, having it FIRST register the domain via the third party's API.
    If the domain can not be registered, the script should fail and the some errors should be displayed.

    Thanks!
     
  2. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hi louisliu,

    Let me first outline your requirements to ensure I fully understand.

    1) The root or a reseller user use WHM to create an account.
    2) Account creation is dependent on registering the new account's intended domain with a Registar (via their API)
    3) If the domain registration is not successful, then account creation is unsuccessful. An error should be displayed within WHM stating the specific reason.


    Well, short answer is that the various hooks systems either spawn separate processes (which couldn't preempt account creation, ie Function Hooks, Script Hooks) or receives their information on a level that WHM don't report, ( cPanel API level, ie CustomEventHandler). Your real option will require some significate coding.

    I think the best opinion for you would be a WHM Plugin. WHM Plugins are CGI scripts, so is can be Perl or PHP. Your plugin would be a wrapper of sorts; maybe more like a mini application. You'd present a New Account form, similar to the one under Account Functions, but when the form is submitted it first attempts to register the domain, then tries to create the new account locally (either by executing /scripts/wwwacct or via the XML-API).

    Even if there was a way to accomplish the 'do other stuff first and possibly fail' scenario with one of our hooks, I think you're best served doing a plugin if only for the reason that domain registration could be a rather lengthy and sophisticated bit of code. If you're customization was more application like, then you could actually do some very useful things, like besides just say there was a problem. For instance you could fully leverage either the domain registar's API or a payment gateway to ensure secure and PCI compliant transactions for the new domain.


    Take a look at that stuff and post back if you have any questions,
    -DavidN
     
  3. louisliu

    louisliu Registered

    Joined:
    Oct 1, 2010
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Thanks cPanelDavidN!

    Your outline is correct.

    WHM plugins may be the best solution, but i think your short answer is what i want to find, do you give me more informations to solve my question?

    Thanks!
     
  4. brianoz

    brianoz Well-Known Member

    Joined:
    Mar 13, 2004
    Messages:
    1,146
    Likes Received:
    6
    Trophy Points:
    38
    Location:
    Melbourne, Australia
    cPanel Access Level:
    Root Administrator
    Normally this is all done by a billing solution that sits above WHM/cpanel - one very good such solution is WHMCS. The billing system collects payment, creates invoice and payment audit trails, and then registers the domain and creates the account in WHM [via cPanel API]. In other words, you're kind of doing it backwards!

    What are the reasons you need to do it this way? Not to say there might not be very good reasons, but understanding them in this point is key to providing reasoned advice.
     
    #4 brianoz, Oct 3, 2010
    Last edited: Oct 3, 2010
  5. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    I think Brian has a very good point. Normally, a billing solution that can talk to the registar's APIs and the WHM/cPanel's APIs is what people use.

    I think that any 'short answer' solution that I could dream up would be too fragile and overly complicated. A WHM Plugin, or some third party billing solution would work much better in the long term (and maybe short term too).

    Regards,
    -DavidN
     
Loading...

Share This Page