Jump to content

WHMCS automation using installatron. code kinda works


stickyn1

Recommended Posts

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");

?>  

Link to comment
Share on other sites

ALL I NEED IS:

Someone to look at my (if, else if) statements. The code works except after the first IF statement. It WILL install, and communicate with the installatron. It will install my custom package if divi is selected. However if a user selects "Extra, or theme3" the values are not read, and nothing but the default package is installed.

 

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;
   }

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