WHM Post Account Creation Script

adalpe

Registered
Aug 28, 2010
2
0
51
Hiya!

I have a script that I am currently configuring:

PHP:
<?php
$resource1 = mysql_connect('connection string 1');
$db = mysql_select_db(admin_plus, $resource1)
               or die ("Couldn't select database.");
$resource2 = mysql_connect('connection string 2');
$db = mysql_select_db(admin_image, $resource2)
               or die ("Couldn't select database.");
$sql = "SELECT email FROM users";
$query = mysql_query($sql, $resource1);
for ($i=0;$i<($result = mysql_fetch_assoc($query));$i++) {
    mysql_query("INSERT INTO details ('email') VALUES('email') ($resource2)");
}

mysql_close($resource1);
mysql_close($resource2);   
?>
That I want to run straight after an account creation, to pull the email address from a clientexec account and put it into my own database table. I then plan to get the user to configure their own details etc.

My problem is, this is only for one type of hosting that I am providing. It is a hosting account that comes accompanied with various software to accomplish some specific tasks, and I don't want anybody else to be able to access it.

If there any way I can get this script to run *only* after a specific package has been created?

Regards,

Adam
 

adalpe

Registered
Aug 28, 2010
2
0
51
I would also like to extend this question to ask how you can obtain the newly created account details (email address) etc. from cPanel

Regards,

Adam.
 

cPanelDavidN

Well-Known Member
Staff member
Dec 17, 2009
571
3
68
Houston, TX
cPanel Access Level
Root Administrator
Hi Adam,

Will this be running based on a particular reseller account or will root or multiple resellers possibly be using this for accounts they create?

The simplest method to have a script fire off after account creation is by using a postwwwacct Script Hook. This is the documentation and here's a blog post about using it (coupled with the XMLAPI) create databases. However, Script Hooks are installed and executed by root, so if you only have reseller access I'm afraid that method is not feasible.

Assuming that you do have root, and you do choose to use a Script Hook, your Script Hook will be passed variables containing all the information that was use to create the account within WHM (or any other method of account creation, ie CLI or XMLAPI). You can use this information to determine which package as chosen and only perform the additional action as necessary.

Let me know if you have any specific questions,
-DavidN
 

MrLeN

Active Member
Dec 12, 2010
38
0
56
Hi Adam,

Will this be running based on a particular reseller account or will root or multiple resellers possibly be using this for accounts they create?

The simplest method to have a script fire off after account creation is by using a postwwwacct Script Hook. This is the documentation and here's a blog post about using it (coupled with the XMLAPI) create databases. However, Script Hooks are installed and executed by root, so if you only have reseller access I'm afraid that method is not feasible.

Assuming that you do have root, and you do choose to use a Script Hook, your Script Hook will be passed variables containing all the information that was use to create the account within WHM (or any other method of account creation, ie CLI or XMLAPI). You can use this information to determine which package as chosen and only perform the additional action as necessary.

Let me know if you have any specific questions,
-DavidN
Can I use this to modify a package, after an account has been created?
 

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,212
13
313
Houston, TX
cPanel Access Level
Root Administrator
Can I use this to modify a package, after an account has been created?
This thread is more about doing things regardless of how an account was created, whether it was created in WHM, by some billing automation tool like WHMCS or by a PHP script that just creates accounts.

If you are just looking to modify a package assigned to an account after you have created an account in a PHP script, it would be much simpler to just do that in the same PHP script after the account was created.