I have some code that does not work, I think i may of wrote it wrong.
The below codes are hooks inside the WHMCS hooks folder. It tells the installatron "one click app installer" to install a pre-built WordPress theme by using the templates ID. The code also imports over usernames, passwords, and site title. The above code works great, however it stops working after the first "IF". it will install with option "divi" selected. any other options it will not install anything.
The first section below works great.
if($vars["params"]["customfields"]["Theme"] === "divi")
{
$contentid = "2wzimd6mgticcg4osc0sgk04g";
}
The second section with value of "=="extra" and "theme3 does not work.
<?php
function installatron_autoinstall($vars)
{
// Exit if a hosting account is not being provisioned. We don't want to be here!
if ( $vars["params"]["type"] !== "hostingaccount" )
{
return;
}
//CODE BELOW: Adds hosting pacakges ie...1,2,3...from the WHM
//if(intval($vars["params"]["packageid"]) !== 2){
// return;
//}
//Below we are selecting a pre-built wordpress theme with the content ID
//found in the installatron admin settings. This template ID is at the end of the .appdata string under
//files & tables
if($vars["params"]["customfields"]["Theme"] === "divi")
{
$contentid = "2wzimd6mgticcg4osc0sgk04g";
}
else if($vars["params"]["customfields"]["Theme"] === "extra")
{
$contentid = "2wzimd6mgticcg4osc0sgk04g";
}
else if($vars["params"]["customfields"]["Theme"] === "theme3")
{
$contentid = "cso44k8ym1s0s8kk02vnrxgo4";
}
else
{
return;
}
$query = array(
"cmd" => "install",
"background" => "yes",//execute as a background process
"application" => "wordpress",
"url" => "http://".$vars["params"]["domain"],
"login" => $vars["params"]["customfields"]["Username"],//custom field in WHMCS "Verbatim"
"passwd" => $vars["params"]["customfields"]["Password"],//custom field in WHMCS "Verbatim"
"sitetitle" => $vars["params"]["customfields"]["Title"],//custom field in WHMCS "Verbatim"
"content" => $contentid,//matches custom ID above which tells wordpredd what to install
);
$response = _installatron_call_v2($vars, $query);
if ( $response["result"] === false )
{
error_log("Installatron API Error: ".var_export($response,true)."\nRequest: ".var_export($vars["params"],true), 3, "/tmp/whmcs_installatron_error_log");
return;
}
// Success!
//echo $response["message"];
}
add_hook("AfterModuleCreate", 9, "installatron_autoinstall");
?>