arctabyte Posted November 8, 2013 Share Posted November 8, 2013 Hi, Is there anyway to schedule account suspension? For example in a case when an account has reached it allocated disk space, we send an email notification that we will hold them for 2 days then we will suspend them if no action has been taken. What is the best way to do this? Currently we are doing it manually, putting a reminder we should check again after 2 days. Thanks 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 8, 2013 Share Posted November 8, 2013 http://docs.whmcs.com/Automation_Settings#Enable_Suspension 0 Quote Link to comment Share on other sites More sharing options...
arctabyte Posted November 9, 2013 Author Share Posted November 9, 2013 Thanks for the reply. Not really the answer I'm looking for, since the automatic suspension module was triggered by overdue on payment. What I am asking is how to set suspension after x days on an account, for example in my case: exceeded disk storage capacity. 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted November 9, 2013 Share Posted November 9, 2013 (edited) It's quite simple. You should run a code like this via CRON // Let's say that with this fanta-query you retreive disk usage and the ID of the product or service you have on WHMCS for clientdomain.net $result = mysql_query("SELECT disk_usage, serviceid FROM table WHERE domain = 'clientdomain.net'"); $row = mysql_fetch_assoc($result); // If disk usage exceeds your limit - let's suppose that it's 1000 MB - then we run ModuleSuspend API Function if($row["disk_usage"]>="1000 MB") { $posturl = "http://yourwhmcs.com/includes/api.php"; # Your WHMCS API URL $username = "yourusername"; # Your WHMCS Admin $password = "yourpassword"; # Your WHMCS Password $postfields["username"] = $username; $postfields["password"] = md5($password); $postfields["action"] = "modulesuspend"; $postfields["accountid"] = $row["serviceid"]; # We are suspending the product/service with this particular ID $postfields["suspendreason"] = "You are using ".$row["disk_usage"]." of 1000 MB!"; # If you want you can also specify a Suspend Reason // Post data via CURL(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $posturl); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); $data = curl_exec($ch); curl_close($ch); $data = explode(";",$data); foreach ($data AS $temp) { $temp = explode("=",$temp); $results[$temp[0]] = $temp[1]; } if ($results["result"]=="success") { # Result was OK! } else { # An error occured echo "The following error occured: ".$results["message"]; } } I use it a lot to automatically terminate, suspend and unsuspend particular services and domains. Edited November 9, 2013 by Kian 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.