Jump to content

Scheduling Account Suspension


arctabyte

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by Kian
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.

  • 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