Jump to content

WHMCS Licence Module - Automated termination.


Recommended Posts

Hello,

Is anybody able to assist with a issue I’m having with my WHMCS licence module. The WHMCS licence module is a module which automatically registers/creates WHMCS licences. 

The idea is that you could utilise the daily cron hook point to run some additional code to check every WHMCS licence addon’s check the next due date and cancel the license if it’s in the past. 

I don’t believe that this would be too difficult to code but I am not familiar with this. It would be greatly appreciated if somebody could code this for me. 

Thanks! 

Link to comment
Share on other sites

On 4/15/2022 at 2:49 AM, Rowan S said:

Hello,

Is anybody able to assist with a issue I’m having with my WHMCS licence module. The WHMCS licence module is a module which automatically registers/creates WHMCS licences. 

The idea is that you could utilise the daily cron hook point to run some additional code to check every WHMCS licence addon’s check the next due date and cancel the license if it’s in the past. 

I don’t believe that this would be too difficult to code but I am not familiar with this. It would be greatly appreciated if somebody could code this for me. 

Thanks! 

Hi @Rowan S

We can help you with the issue you are facing in your License Module. We are familiar with this kind of issues.

You can simply click here to submit a ticket on our website to start the process.

Looking forward for to work with you.

Regards

Link to comment
Share on other sites

This should do the job:

<?php

use WHMCS\Database\Capsule;


add_hook('DailyCronJob', 1, function($vars) {
    $today = toMySQLDate(getTodaysDate(false));

    $products = Capsule::Table('tblhosting')
        ->select('id')
        ->where('status', 'Active')
        ->where('nextduedate', '<=', $today)
        ->get();
        
    foreach($products as $product){
        $command = 'ModuleTerminate';
        $postData = array(
            'serviceid' => $products->id,
        );
            
        localAPI($command, $postData);       
    }
     
});

It'll work for all products, however. You should add a 'where' clause to only get specific products.

Link to comment
Share on other sites

16 hours ago, DennisHermannsen said:

This should do the job:


<?php

use WHMCS\Database\Capsule;


add_hook('DailyCronJob', 1, function($vars) {
    $today = toMySQLDate(getTodaysDate(false));

    $products = Capsule::Table('tblhosting')
        ->select('id')
        ->where('status', 'Active')
        ->where('nextduedate', '<=', $today)
        ->get();
        
    foreach($products as $product){
        $command = 'ModuleTerminate';
        $postData = array(
            'serviceid' => $products->id,
        );
            
        localAPI($command, $postData);       
    }
     
});

It'll work for all products, however. You should add a 'where' clause to only get specific products.

Hiya,

thank you so much for providing this for me. I’ll give it a go in the development environment and get back to you. 
 

Thanks!

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.

×
×
  • 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