So, WHMCS has the ability for you to isolate the cron directory. This is a great feature, as it provides a bit of security. What if you wanted to add cron files to WHMCS though? For example, what if you really didn’t want something as a hook, but only run once in a while (say, every day, two days, etc)? How would you go about this? This guide will walk you through adding cron files to WHMCS, and tying them into the system.
Firstly, it’s important to note that you should probably not do this. For the most part, you’ll want to use one of the three hooks designed in WHMCS to do specifically this. I mean, that’s what the system is for , right? However, there are times when you may want to need to be adding cron files to WHMCS. For example, let’s say you’re running something like our WHMCS Notifications Extended addon, and you want to add a cron job to ping the WHMCS database and make sure that everything was as it should be and tickets weren’t falling behind. Well, this would be an absolutely legitimate use of this.
Creating code for ‘crons’ is a bit different than creating a pageÂ . There’s a bit more to it, so we’ll walk you through adding cron files to WHMCS.
Save this php file as a ‘template’ as it were, in your crons directory. You’ll need to do a good bit of work to get it to work for you, but this will start
<?php //let's leave this in admin shall we? require_once("config.php"); require_once("functions.php"); require_once("bootstrap.php"); use Illuminate\Database\Capsule\Manager as Capsule; //Now, add your code in here . You've got a working start
Using things this way, you’re able to call the database, tie into the WHMCS system as best your able. Your custom hooks should be available, as well as everything else you need.