tsgeoff Posted January 29, 2013 Share Posted January 29, 2013 Hi all. I'm a newcomer to WHMCS, so please forgive me if this is obvious. I have tried searching, but cannot find a solution. My question is as follows: My application consists of two independent systems - with the user accounts synchronised between them. Currently, I'm making use of the ClientEdit hook to update the non-WHMCS system with the client's new details every time the client's details are updated. However, due to the fact this is a third-party API that is called (via HTTP request), there is the chance for failure. So how, from the hook, would I be able to display an error or other message to the client, alerting them to the fact that their update has actually failed? Currently, I cannot set such a message and as such (regardless of whether my third-party integration actually happened), a success message is displayed. Any help in this regard would really be helpful! Thanks, Geoff 0 Quote Link to comment Share on other sites More sharing options...
WHMCS JamesX Posted January 30, 2013 Share Posted January 30, 2013 The more-or-less standard variable to return an error message within the client area from a client area hook is something like below: global $errormessage; $errormessage .= ''; 0 Quote Link to comment Share on other sites More sharing options...
tsgeoff Posted January 30, 2013 Author Share Posted January 30, 2013 Hey James. Thanks for the response. The fact that it is $errormessage to me implies it will indicate an error. Is there any way to indicate anything else - such as a warning or success message? I'm only needing to indicate an error message at the moment - but it might be good to know for future use. 0 Quote Link to comment Share on other sites More sharing options...
WHMCS JamesX Posted January 30, 2013 Share Posted January 30, 2013 (edited) The fact that it is $errormessage to me implies it will indicate an error. Yes, you'd use $errormessage to return an error message. Is there any way to indicate anything else - such as a warning or success message? I'm only needing to indicate an error message at the moment - but it might be good to know for future use. For the most part, that depends upon the specific hook point and page. For example, within the clientareadetails.tpl, the changes saved successfully message is displayed when $successful is set. You could either update the appropriate language string to include text relating to your external update, you could define an entirely new smarty variable and display your own custom success message for the remote update in addition to the standard one, etc. Edited January 30, 2013 by WHMCS JamesX 0 Quote Link to comment Share on other sites More sharing options...
tsgeoff Posted January 30, 2013 Author Share Posted January 30, 2013 (edited) Ah, okay. I see. To be honest - I completely forgot about the fact that the area is templated - so I can update my template to whatever I want. However, this is where another issue coming in (additionally, updating $errormessage According to the WHMCS documentation, there are no return variables for the ClientEdit hook. Which is fine - if I was able to find out how to send custom variables through the template. I've done some digging around with dumping out declared classes and objects, and I can't seem to find any way in which I would be able to send a custom variable through to the template. Perhaps I've overlooked something? Have you ever needed to do something like this? EDIT: So, I was playing around some more, and came across a variable called [highlight]$smartyvalues[/highlight], which seems to contain the values. function hook_name ($vars) { global $smartyvalues; $smartyvalues['myvarname'] = 'foo'; // {$myvarname} now becomes available in your template. } This can be used to override the error messages, and any variables that may have already been set by WHMCS (such as the {$success} or {$errormessage} variables in the template - I found that global $errormessage didn't work for me). I thought I might include this information in case anyone came across the same issue / need as I did. Edited January 30, 2013 by tsgeoff Found more information 0 Quote Link to comment Share on other sites More sharing options...
WHMCS JamesX Posted January 30, 2013 Share Posted January 30, 2013 Ya, exactly how to go about it depends on when the hook point is executed during the flow of a particular page/process. Everything's working for you now though? 0 Quote Link to comment Share on other sites More sharing options...
tsgeoff Posted January 31, 2013 Author Share Posted January 31, 2013 Hey James. Yeah - everything is working just fine now - thanks 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.