Jump to content
DennisMidjord

Clean up To Do list: Automatically complete 'Pending Domain Transfers' when domain is transferred

Recommended Posts

I simply can't comprehend why WHMCS doesn't do this automatically. Dealing with multiple transfers each day, the To Do list becomes cluttered really fast.

The following hook will execute on 'DomainTransferCompleted', look for Pending Domain Transfers that are In Progress containing the domain name and set all of them to Completed (in case there are multiple entries).

<?php
use WHMCS\Database\Capsule;
add_hook('DomainTransferCompleted', 1, function($vars) {
    //This hook will complete to do items for transfers when the transfer is completed.
	$toDoID = Capsule::table('tbltodolist')
		->where('status', 'In Progress')
		->where('title', 'Domain Pending Transfer')
		->where('description', 'LIKE', '% ' . $vars["domain"] . ' %')
		->get();
	
	//Loop through the ID's and set them as completed.
	foreach ($toDoID as $entry) {
		$command = 'UpdateToDoItem';
		$postData = array(
		'itemid' => $entry->id,
		'adminid' => '1',
		'status' => 'Completed',
	);

	$results = localAPI($command, $postData);
	print_r($results);
	}

});

Place the file in /includes/hooks/.

UpdateToDo.php

Edited by DennisMidjord

Share this post


Link to post
Share on other sites

Made a very small typo in the first. Use this instead:

<?php
use WHMCS\Database\Capsule;
add_hook('DomainTransferCompleted', 1, function($vars) {
    //This hook will complete to do items for transfers when the transfer is completed.
	$toDoID = Capsule::table('tbltodolist')
		->where('status', 'In Progress')
		->where('title', 'Domain Pending Transfer')
		->where('description', 'LIKE', '% ' . $vars["domain"] . '%')
		->get();
	
	//Loop through the ID's and set them as completed.
	foreach ($toDoID as $entry) {
		$command = 'UpdateToDoItem';
		$postData = array(
		'itemid' => $entry->id,
		'adminid' => '1',
		'status' => 'Completed',
	);

	$results = localAPI($command, $postData);
	}

});

Remember to update 'adminid' with the actual ID of an admin.

UpdateToDo.php

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated