I submitted a related query: Redirect to custompage.php instead of viewinvoice.php if payment fails in WHMCS Vs 6.2.0, and I got a brilliant response which i successfully implemented.
I wish to port my code solution into a custom built WHMCS addon module if possible by leveraging the WHMCS _output function of the addon module, to output transaction failed messages from the payment gateway.
I undestand that, Hooks that the module should define within WHMCS are defined in a file named “hooks.php”. This should be within my module folder.
My design objective is to detect if I am on viewinvoice.php page, then redirect within the hook to the addon module file as shown below:
add_hook('ClientAreaPage', 1, function($templateVariables)
{
if($templateVariables["filename"] == "viewinvoice" AND $templateVariables["paymentSuccess"] == false)
{
// store variables to send to the addon module file.
$_SESSION['bemasTransactionDetails'] = $templateVariables["invoiceid"];
// redirect to addon page ????
header('location:'. addon_module_file);
die;
}
});
This is not working.
How do I redirect to the WHMCS addon module file from the module hook? Or am I approaching the problem the wrong way?
Can any one give me a hint?