Jump to content
Sign in to follow this  

Auto-Terminate Free Trials After X Minutes

Recommended Posts

Free trials for a limited period is a good marketing strategy to capitalize on the leads you get. The problem with trials is that the smallest unit of time for WHMCS is the day meaning that for example you can't provide a trial for VPS that last for a couple of hours. WHMCS can't "think" for a period of less than a full day.

The following action hook allows to automatically terminate the given products/services after a certain number of minutes. It runs AfterCronJob hook point that normally triggers once every 5 minutes. Visit Setup > Automation Settings and make sure that cron.php runs every 5 minutes as suggested by WHMCS. The hook will do the rest. It also logs terminations in Activity Log.

Get the Code »

Share this post

Link to post
Share on other sites

The script has been updated with two new features.

First. You can perform Termination or Suspension.

Second. The previous version of the hook worked only for products/services using a server module (eg. Plesk, cPanel etc.). Now it works also with "basic" services not assigned to any server module. In other words services with no Create, Suspend, Unuspend and Terminate button. In this case the script updates the status accordigly.

I'm also planning to make the hook work with multiple conditions like in the following example:

  • Product ID 10 suspended after 10 minutes
  • Product ID 12, 13 and 14 suspended after 8 hours
Edited by Kian

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Similar Content

    • By mf70
      hello everyone
      i have 2 error in cron what should i do ?

    • By ebbydare
      I noticed that since I updated my whmcs to 8.0.4, my cron job has not been working effectively. It's scheduled to run every 5 minutes but its been running every 24 hours. It's as if there is a script in the cron.php that is making it run every 24 hours but I don't know which and what. I'll appreciate any help
    • By Kian
      Restrict the access to support departments based on the products purchased by users. Define rules as follows.
      $department['1'] = array('45', '46', '10'); $department['2'] = array('85', '86', '10'); // Keep adding rules one per line The key of $department array (the [1] and [2] between square brackets) corresponds to the ID of the support department for which we are creating a rule. The value is an array() of product IDs required for access. In a in nutshell, the above configuration unlocks department #1 to users with product IDs 45, 46 and 10. Department #2 requires 85, 86 and 10.
      Here are few more things to consider:
      submitticket.php doesn't show restricted departments Access via direct link submitticket.php?step=2&deptid=2 triggers a redirect to submitticket.php Department dropdown lists only allowed department The same product can be used for multiple rules Pending, Suspended, Terminated, Cancelled and Fraud products are ignored Get the Code »
    • By Kian
      Client group background colors no longer display on ticket view page. Go figure out why WHMCS decided to remove it from v8. This action hook puts the styling back.

      Get the Code »
    • By Jameszz1
      The cron task needs 20-40 minutes a day to be executed. (During cron running time, 502 errors may occur for any operation)
      How should I optimize it?
      Please advise

  • Recently Browsing   0 members

    No registered users viewing this page.

  • 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