WHMCS Auto Install Module
This guide will help you to setup WHMCS to auto-install scripts during user account creation. Setting this up is very easy. This guide assumes that you have already installed Softaculous on your server.
Note: This works only with cPanel and DirectAdmin at the moment.
List of Scripts
All the scripts in Softaculous can be Auto Installed. Following is the popular list of scripts :
WordPress, b2evolution, StatusNet, Drupal, Mambo, phpBB, SMF, AEF, Coppermine, Gallery, Jcow, OpenClassifieds, openX, WebCalendar, Shadows Rising, phpList, SquirrelMail, LimeSurvey, Piwik, SugarCRM, PHProjekt, osCommerce, Magento, phpBook, HESK, osTicket, kPlaylist, VidiScript, Gregarius, CodeIgniter, Moodle, Elgg.
(See the first pic to see where you have to add the names of scripts, the box outlined in red is where you add the list of scripts.)
Download and Upload
Download the Auto Installation Hook from the Downloads Sections.
Unzip it and upload the file called softaculous.php, in your /path/to/whmcs/includes/hooks/ Directory. If you want to debug for any errors or test the Auto Install is working properly please also upload the softaculous_debug.php file in your /path/to/whmcs/includes/hooks/ Directory. You can remove the softaculous_debug.php file later after it works successfully.
If you want to add Auto Installation for Custom Scripts then please modify softaculous_extra.php and upload it as well. Otherwise you dont need to upload softaculous_extra.php
Editing a Product/Service
Now login to your WHMCS Admin Panel. This guide assumes you have already setup WHMCS to create user accounts automatically. If you have not already setup your server you can find detailed guides on the WHMCS Wiki
Setup Custom Fields
Go to Setup -> Products/Services and click on the Edit Product Icon of the Product you wish to setup Auto Installation for.
In the Edit Product section, click the 'Custom Fields' tab.
In the Custom Fields tab > Add New Custom Field.
We will have to add 4 Custom Fields.
You can only add 1 Custom Field at a time, so after adding the first field hit the 'Save Changes' button, for the 2nd field to show up.
This is how we add custom fields.
See the images below for the 4 custom fields.
Note : You can give "None" as the first option in the List of Scripts. If users dont want to install a script when their account is created, they can choose "None" to refrain from installing any script.
Very Important Note : Fill in the fields name as per the image only. IF you wish to modify the Field Names (e.g. "Admin Username" instead of "Admin Name") then you must upload the softaculous_extra.php file as well (it has sample code to modify the field names).
Additional Custom Fields
You can also setup additional Fields for optional parameters like "Site Name", "Site Description", etc.
Continue adding the Fields that you wish similarly as you did above.
You need to make one more change in the softaculous_extra.php
You need to create an Array $softaculous_conf['custom_fields'] add the number of fields you want to add in this array the key of the array will be the name of the field in the install.xml file of the script.
For Eg: If you want to add the Site Name field for WordPress
1. Go to /var/softaculous/wp/install.xml
2. Search for the site name field, you will get the following code:
<input type="text" name="site_name" size="30" value="My Blog">
3. The key for $softaculous_conf['custom_fields'] will be the name of the input tag i.e. site_name
4. The value for $softaculous_conf['custom_fields'] will be the Custom Field name that you provided in the WHMCS product setup in this case Site Name.
5. The additional field is now setup.
Setup Module Run Time
The Softaculous Hook will run and try to Auto Install the script only when the account is being created. This option can be found while editing the Product/Service in Module Settings Tab. You can choose any of the option in the image shown below. Just remember that Softaculous will create the account only as per the method you select.
Once you are done with the 4 fields, hit the Save Changes button and you are done.
Testing the Setup
You can test the setup by making a DUMMY Order and going to the settings of that order.
For debugging purposes upload softaculous_debug.php in the /path/to/whmcs/includes/hooks/ Directory. If you dont upload the softaculous_debug.php no error messages will be shown.
Make sure the Admin Name and Admin Pass are setup and the desired script is selected e.g. WordPress
Then click on the Create button to create the account on the server.
You will see a Box shown in the following image
When the page reloads (assuming debugging is enabled) the following message will be shown in case of success :
Incase of Failure errors will be shown (assuming debugging is enabled).
There could be several reasons for the Hook Not to work :
- A firewall is blocking requests
- You put the incorrect Field Names
- cURL is disabled in PHP
Remove Debug File
Please remove the softaculous_debug.php file after you have successfully setup the Module.
If you have made a Custom Script in Softaculous and want to enable Auto Installation of that script via WHMCS then please upload the file softaculous_extra.php as well in the hooks folder.
Before uploading the softaculous_extra.php file, please modify it and add the scripts you want to automate installation of.
Please note that the ID of the custom script must be the same as that of the Custom Script in Softaculous Admin Panel.
If you need any assistance then please contact Softaculous Support. Please send us a screenshot of the Order Form and the Custom Fields you added to the Product.