Jump to content

API: ChangePackage fails to change package - please help


onklmaps

Recommended Posts

Hi,

 

After much trial and error I'm asking here, and hopefully getting some insight from one of you experts :!:

 

I want to change the whm package directly after a client has ordered a cpanel hosting account from whmcs.

The reason I want to do this, is that my Installatron auto-installer hook script needs to call the Installatron API from the cPanel-account. As soon as the initial call is done, root takes over and finishes the task, and the cPanel-account no longer needs the Installatron feature activated.

 

So therefore, at AfterModuleCreate-hook i run the installatron script with priority 1 first, and then my downgrade script with priority 2.

Both scripts run fine, but my downgrade script fails to do what is intended. It does not change to the downgraded whm-package, but keeps the full featured one. Please see the code:

 

<?php
function downPackage($vars) {
$command = 'ModuleChangePackage';
$postData = array(
'accountid' => $vars['params']['accountid'],
'user' => $vars['params']['username'],
'pkg' => 'name_of_the_downgraded_whm_package', // New whm-package I want to change too. 
);
$adminUsername = 'admin';
$results = localAPI($command, $postData, $adminUsername); 
}
add_hook("AfterModuleCreate",2,"downPackage");
?>

 

Please see the System Module Debug Log > Request:

user=cpaneluser&pkg=name_of_full_featured_whm_package

 

Request has the wrong pkg name! Why is that, and how can I correct it?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated