This simple WHMCS hook adds few details about services managed by the WHMCS auto-release module.

Auto-release is a handy way to manage in WHMCS external services manually, and it's useful for services that have no full integration modules available.

But if you set to manage them using internal to-do utility, it may be annoying because WHMCS will report just the service ID and a short description of action required (renew, suspend, etc.)

This simple hook will add also service name, making the following job easier faster, and even more safe (it may happen that you open the service with a wrong ID, so i.e. you go on renewing the wrong service...)

This hook is available also on GitHub repository:  https://github.com/DomainRegister/WHMCS-enhanced-auto-release

 

<?php
//
// enhanced to-do
// WHMCS hook to enrich details about services managed by auto-release module
//
// https://domainregister.international/
//

add_hook('AfterCronJob', 100, function($vars) {

try {
$todoitem = Capsule::table('tbltodolist')
->where('status', '!=', 'Completed')
->where('description', 'like', 'Service ID # %')
->select('id','description')
->first();

} catch (\Exception $e) {
echo "error {$e->getMessage()}";
}

$descr2=substr($todoitem->description,12);
$serviceid=intval($descr2);
$descr3=preg_replace( '/Service ID # \d+/', '', $todoitem->description );


try {
$servicename = Capsule::table('tblhosting')
->where("id", $serviceid)
->select('domain')
->first();
echo "<pre>"; print_r($servicename);

} catch(\Illuminate\Database\QueryException $ex){
echo $ex->getMessage();
} catch (Exception $e) {
echo $e->getMessage();
}

$newdescription = 'Service ID #'.$serviceid.' ( '.$servicename->domain.' ) '.$descr3.PHP_EOL;

try {
$update_data = [
'description' => $newdescription
];
Capsule::table('tbltodolist')
->where('id', '=', $todoitem->id)
->update($update_data);
} catch(\Illuminate\Database\QueryException $ex){
echo $ex->getMessage();
} catch (Exception $e) {
echo $e->getMessage();
}

});

 

 

Found this article interesting?
Subscribe to DomainRegister´s newsletter!

You can unsubscribe at any time by simply clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp s privacy practices here.

  • WHMCS
  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

 How to add a favicon in WHMCS

To add a favicon to your WHMCS install: copy your favicon (es. myfavicon.ico) in WHMCS folder...

 How to comment in template (.tpl) files

If you need to insert a comment in a .tpl file, or comment a block of code to disable it, you...

 How to insert a Youtube video in WHMCS knowledgebase article

To insert a YouTube video in an article of the WHMCS knowledge base, you need to insert following...

 How to disable a customer to pay invoices partly with credit balance

in WHMCS if a customer has not enough credit balance for full payment of an invoice, WHMCS allows...

 How to add a cookie bar to WHMCS

In order to add a cookie bar to your own installation of WHMCS: copy somewhere on your WHMCS...