Free Hosting Accounts in WHMCS


How to Enable Free Trial Hosting Accounts in WHMCS

As you would create any other hosting plan, create a new hosting plan in WHMCS and make it free.

Scroll down for the two files content which you may copy and paste into notepad or create directly on your server.

Then create these two files which you need to run every day using cron job:

  • remindtrial.php.txt - rename this file to remindtrial.php and run it every day using cron job: 0 8 * * * php -q /path/to/your/whmcs/remindtrial.php
  • removetrial.php.txt - rename this file to removetrial.php and run it every day using cron job:  0 7 * * * php -q /path/to/your/whmcs/removetrial.php

Change /path/to/your/whmcs/ to the location of your WHMCS installation directory

remindtrial.php will send out reminder to your free trial account holder reminding them that the account will self destruct in x more days and guiding them how they can upgrade their account into a paid one.

removetrial.php will simply insert the free trial accounts into WHMCS cancellation requests which will be terminated "immediately" when the next WHMCS cron runs. So all the trial accounts will self terminate.

 

Edit those two files and enter in your own preferences into the php codes.

Important note, as this is a hard coded file, you need to edit this line:

$sql_gettrial = "select id from tblhosting where DATEDIFF(now(),regdate)=$trial_period_days and (packageid=XX or packageid=XX)";

See the packageid=xx or packageid=xx, simply replace that with YOUR OWN hosting package ID which you can see from WHMCS by hovering your mouse over the "Edit" product details, you will see the package id or product id of your trial products.
You can alos view this ID by clicking on and opening the edit product section of said particular product and then viewing the address in the address bar. The last number of the address is the product number.

 

Create these files below. Remembering these files need to be edited with information relating to your WHMCS Installation, passwords, database details, website addresses, email addresses and the like. Most the required information can be accessed from your current configuration.php file within your WHMCS installation. 

remindtrial.php.txt


<?php
$user_whmcs = "db_user";
$password_whmcs="db_pwd";
$host_whmcs="db_hostname";
$database_whmcs="db_name";
$remind_trial_days = "4";
$clientArea = "https://yourdomain.com/whmcs/clientarea.php";

$whmcs_conn_string=mysql_connect($host_whmcs,$user_whmcs,$password_whmcs);
$whmcs_dbconn=mysql_select_db($database_whmcs,$whmcs_conn_string);

$sql_gettrial = "select orderid,userid from tblhosting where DATEDIFF(now(),regdate)=$remind_trial_days and (packageid=16 or packageid=17)";
$rs_gettrial = mysql_query($sql_gettrial);

while($row = mysql_fetch_array($rs_gettrial, MYSQL_ASSOC))
{
$orderid = $row['orderid'];
$userid = $row['userid'];
$rs_getemail = mysql_query("SELECT email FROM tblclients WHERE id = ".$userid."");
$ada_email = mysql_numrows($rs_getemail);

while($rowemail = mysql_fetch_array($rs_getemail, MYSQL_ASSOC))
{
$mailme = $rowemail['email'];

$Name = "WebHost.Com"; //senders name
$email = "admin@webhost.com"; //senders e-mail adress
$recipient = $mailme; //recipient
$mail_body = "Hello,
This is a reminder that your Trial Acccount will be terminated in three days. All data within this account will be terminated if you do not upgrade your account.

This is the only and last reminder for you to upgrade your account. Please follow the steps below when you decide to keep the account.

UPGRADING A TRIAL ACCOUNT TO A REGULLAR ACCOUNT:
To upgrade to a regullar account, you must follow these steps:
1. Login to the client area at $clientArea using your email address and password\n
2. Click on My Hosting Packages from the left navigation menu\n
3. Click on View Details on your hosting package\n
4. Click on Upgrade/Downgrade Package\n
5. Choose the respective hosting plan\n
6. Click the continue button, then Make Payment by clicking the Invoice Number\n
7. Upon making payment your account will be upgraded.\n

If you do not wish to continue using your web hosting account, please ignore this email, your account will be automatically terminated in three days.

Thank you for using our trial account!"; //mail body
$subject = "Your Hosting Trial Account Termination Reminder"; //subject
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields

mail($recipient, $subject, $mail_body, $header); //mail command :)

}

}

print "Trial reminders sent!";
?>


removetrial.php.txt

<?php
$user_whmcs = "db_user";
$password_whmcs="db_pwd";
$host_whmcs="db_hostname";
$database_whmcs="db_name";
$trial_period_days = "7";

$whmcs_conn_string=mysql_connect($host_whmcs,$user_whmcs,$password_whmcs);
$whmcs_dbconn=mysql_select_db($database_whmcs,$whmcs_conn_string);

$sql_gettrial = "select id from tblhosting where DATEDIFF(now(),regdate)=$trial_period_days and (packageid=16 or packageid=17)";
$rs_gettrial = mysql_query($sql_gettrial);

while($row = mysql_fetch_array($rs_gettrial, MYSQL_ASSOC))
{
$id = $row['id'];

$sql_addremove = "insert into tblcancelrequests (date,relid,reason,type)
VALUES (now(),".$id.",'Free Trial Account','Immediate')";
$rs_addremove = mysql_query($sql_addremove);
print "$id <br />";
}

print "Trial accounts removal inserted!";
?>



  • FREE HOSTING, FREE SSL, FREE , MAD!,, FREE WEBSITE, FREE DOMAIN HOSTING, HOSTING TRIAL, FREE TRIALS
  • 0 Пользователи нашли это полезным
Помог ли вам данный ответ?

Related Articles

TERMS OF SERVICE

 Terms of Service on Checkout Page This simple template addition replaces the Terms of...

WHMCS FREE ADDONS

http://whmcsaddon.comFREE LIVE CHAT FREE TWO FACTOR AUTHENTICATION 

WHMCS TICKET EXPLOIT

Please familiarise yourself and beware of these things. Rogue tickets in your system may be a...

WHMCS HACKER CAUGHT USING EXPLOITS

Known information about a hacker going around Hacking into WHMCS Systems. Going by the name...

WHMCS OATH / TWO FACTOR AUTHENTICATION

https://bitbucket.org/Doctor_McKay/whmcs-oath-addon/src/tip/README.mdDOWNLOAD HERE...