Mike Solstice Posted January 18, 2010 Share Posted January 18, 2010 Ok...so I'm pretty new to WHMCS and PHP in general, trying to learn how to create action hooks. The basic idea here is that after WHMCS runs ModuleCreate which connects to cPanel/WHM, creates the user/domain/etc. it will execute this script to create a mysql database in the newly created user's account. I have everything else working, if I manually put in the username & password, save/upload/execute the script goes off without a hitch. The problem is I can't figure out how to set the variables passed on by the AfterModuleCreate action hook. If I function create_forum_account($vars) { print_r($vars); } add_hook("AfterModuleCreate",1,"create_forum_account"); then when the account is created I get: Array ( [params] => Array ( [accountid] => 123 [serviceid] => 123 [domain] => example.com [username] => abcdefg [password] => gfedcba [packageid] => 1 [pid] => 1 [serverid] => 1 [customfields] => Array ( ) [configoptions] => Array ( ) [type] => hostingaccount [producttype] => hostingaccount [moduletype] => cpanel [configoption1] => some_hosting_plan [configoption2] => 0 [configoption3] => 10 [configoption4] => 0 [configoption5] => 500 [configoption6] => [configoption7] => [configoption8] => 1 [configoption9] => [configoption10] => 0 [configoption11] => [configoption12] => 0 [configoption13] => x3 [configoption14] => 0 [configoption15] => [configoption16] => [configoption17] => 10 [configoption18] => 500 [configoption19] => [configoption20] => [configoption21] => [configoption22] => [configoption23] => [configoption24] => [clientsdetails] => Array ( [userid] => 10 [id] => 10 [firstname] => Ima [lastname] => Luser [companyname] => My Company [email] => User@Example.com [address1] => 123 Any St [address2] => [city] => Anytown [state] => NV [postcode] => 00000 [country] => US [countryname] => United States [phonenumber] => (702) 555-1212 [notes] => [password] => encrypted_password_here [currency] => 1 [cctype] => [cclastfour] => [securityqid] => 4 [securityqans] => My Answer [groupid] => 0 [status] => Active [credit] => 0.00 [taxexempt] => [latefeeoveride] => [overideduenotices] => [language] => [lastlogin] => No Login Logged [billingcid] => 0 ) [server] => 1 ) ) And a few other indexes I'm not including here for security purposes. But then if I $cpanel_user = $vars["username"]; $cpanel_password = $vars["password"]; $cpanel_host = $vars["domain"]; I get Notice: Undefined index: username in /absolute/path/file-to-execute.php on line 8 Notice: Undefined index: password in /absolute/path/file-to-execute.php on line 9 Notice: Undefined index: domain in /absolute/path/file-to-execute.php on line 10 In the example action hook that comes with WHMCS $vars["indexname"] supposedly works fine. I've but the WHMCS documentation is absolutely worthless, staff are rude & the forum queens....don't get me started. I hope this makes sense to someone. Any & all help would be greatly appreciated! Quote Link to comment Share on other sites More sharing options...
ignace Posted January 18, 2010 Share Posted January 18, 2010 Try: $cpanel_user = $vars['params']['username']; Quote Link to comment Share on other sites More sharing options...
Mike Solstice Posted January 18, 2010 Author Share Posted January 18, 2010 Try: $cpanel_user = $vars['params']['username']; That worked, thank you!!! Quote Link to comment Share on other sites More sharing options...
Mike Solstice Posted January 18, 2010 Author Share Posted January 18, 2010 Just to test my understanding, basically what's happening is that AfterModuleCreate is passing on an array within an array, so it's necessary to specify both in the var & b/c I didn't it was only looking at the first array & not finding the index in question? Am I even in the right ballpark here? lol Quote Link to comment Share on other sites More sharing options...
nikizwan Posted August 6, 2011 Share Posted August 6, 2011 How to access the client email? should i use [param] ? thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.