arkdata Posted March 8, 2015 Share Posted March 8, 2015 Hi guys, I've recently purchased a template that integrated WHMCS in the backend. My payment gateway also restricts payment transactions that originates from my main website http://www.arkdata.com.my . However, the Invoice email and reminders still have links that points to the original WHMCS install at portal.arkdata.com.my. Can we change the email template so that the URL reflects the correct URL at https://www.arkdata.com.my/client-area/ ? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 8, 2015 Share Posted March 8, 2015 you could use a Smarty replace on the {$invoice_link} variable to tweak the URL... {$invoice_link|replace:'portal.arkdata.com.my':'www.arkdata.com.my/client-area'} 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted March 8, 2015 Share Posted March 8, 2015 it can be easily done, you will create new file inside "/includes/hooks/" folder with this name "changeEmailTPLURLs.php" and put the following code inside it: <?php function hook_changeEmailTPLURL($vars){ $mergeFields = array(); $mergeFields["whmcs_url"] = "http://custom-url.com/"; return $mergeFields; } add_hook("EmailPreSend", 1, "hook_changeEmailTPLURL"); ?> this hook action will overwrite the {$whmcs_url} to the URL specified in here $mergeFields["whmcs_url"] 0 Quote Link to comment Share on other sites More sharing options...
arkdata Posted March 8, 2015 Author Share Posted March 8, 2015 (edited) it can be easily done, you will create new file inside "/includes/hooks/" folder with this name "changeEmailTPLURLs.php" and put the following code inside it: <?php function hook_changeEmailTPLURL($vars){ $mergeFields = array(); $mergeFields["whmcs_url"] = "http://custom-url.com/"; return $mergeFields; } add_hook("EmailPreSend", 1, "hook_changeEmailTPLURL"); ?> this hook action will overwrite the {$whmcs_url} to the URL specified in here $mergeFields["whmcs_url"] Hi brian!, thanks for the suggestion, however, I'm not a programmer so I don't know how to use a Smarty. Hi sentq, I just did your instructions. How is WHMCS able to know to run the hook for new invoice emails? Is it automated? I'll wait for the next automated invoice email sent to see if it works. Edited March 8, 2015 by arkdata 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 8, 2015 Share Posted March 8, 2015 Hi brian!, thanks for the suggestion, however, I'm not a programmer so I don't know how to use a Smarty. you just need to modify your email template(s) - invoice created and reminders - and replace {$invoice_link} with the code I gave you previously. it was a copy & paste solution! http://docs.whmcs.com/Email_Templates#Conditional_Displays Hi sentq, I just did your instructions. How is WHMCS able to know to run the hook for new invoice emails? Is it automated? if it works, it should do so automatically... however, for your needs, it isn't suitable - in the invoice created/reminder emails, {$whmcs_url} isn't used - it's {$invoice_link} that is used and it creates a link to a specific invoice number. in my opinion, the Smarty replace is the simplest solution. 0 Quote Link to comment Share on other sites More sharing options...
arkdata Posted March 9, 2015 Author Share Posted March 9, 2015 you just need to modify your email template(s) - invoice created and reminders - and replace {$invoice_link} with the code I gave you previously. it was a copy & paste solution! http://docs.whmcs.com/Email_Templates#Conditional_Displays if it works, it should do so automatically... however, for your needs, it isn't suitable - in the invoice created/reminder emails, {$whmcs_url} isn't used - it's {$invoice_link} that is used and it creates a link to a specific invoice number. in my opinion, the Smarty replace is the simplest solution. Hi brian!, looks like your solution is more suitable. Before I break my WHMCS installation is the below steps correct? {$invoice_link|replace:'portal.arkdata.com.my':'www.arkdata.com.my/client-area'} Setup -> Email Templates -> Invoice Created [Original] You can login to your client area to view and pay the invoice at {$invoice_link} [Edited] You can login to your client area to view and pay the invoice at {$invoice_link|replace:'portal.arkdata.com.my':'www.arkdata.com.my/client-area'} 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 9, 2015 Share Posted March 9, 2015 yes that's correct - do that and if you have a test account within your whmcs installation, send yourself an invoice created email and test the link. the idea works as I tried your URL in my dev site and it worked fine, but you'll need to test to see if the modified link goes to the correct page on your wordpress site. 0 Quote Link to comment Share on other sites More sharing options...
arkdata Posted March 9, 2015 Author Share Posted March 9, 2015 Hi brian!, the solution worked but for some reason the template does not display the correct page (Error 404). I'm hardcoding the email template to redirect to client area URL instead. Thanks for the pointers! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 9, 2015 Share Posted March 9, 2015 perhaps the URL you're modifying it to isn't correct? playing with my Dev site, I would imagine (obviously I can't test!) a link to one of your invoices would be along the lines of... client-area/?ccce=viewinvoice.php?id=123 if that works directly for you in your browser, then perhaps the correct modification should be.. {$invoice_link|replace:'portal.arkdata.com.my/':'www.arkdata.com.my/client-area/?ccce='} 0 Quote Link to comment Share on other sites More sharing options...
arkdata Posted March 10, 2015 Author Share Posted March 10, 2015 That makes sense. Let me try! 0 Quote Link to comment Share on other sites More sharing options...
arkdata Posted March 12, 2015 Author Share Posted March 12, 2015 Just to update that it works. Thanks brian! 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.