I am trying to get hooks working. As a test I've created a file called myhooks.php and placed it in the /includes/hooks folder (same location as the WHMCS included hooks example file named example.php). In this file I've created a hook that should fire when an admin changes an invoice to either "Cancelled" or "Unpaid" status. To prove the hook is being called I'm trying to make an internal API call to make an entry in the activity log. I log in with my admin account (for my example we'll say my username is "cesiumdeth"), navigate to an invoice, and change the status back and forth between a status of "Cancelled" and "Unpaid" and save between each change of course. In the whmcs Activity Log I get the default log entry that notes "Modified Invoice Options - Invoice ID: 12345", but I do not see the custom log entry from the call in my code. Anyone see what I'm missing or messed up and why this isn't working? By the way the I've checked that the admin user I'm using in the code does have API permissions (it is a full administrator account with all permissions).
The code in my "myhooks.php" file is as follows:
<?php
function wr_hook_InvoiceChange($vars)
{
$command = "logactivity";
$adminuser = "cesiumdeth";
$values["description"] = "proof wr_hook_InvoiceChange was called";
$results = localAPI($command,$values,$adminuser);
}
add_hook("InvoiceUnpaid",1,"wr_hook_InvoiceChange");
add_hook("InvoiceCancelled",1,"wr_hook_InvoiceChange");
?>