Remitur Posted September 27, 2022 Share Posted September 27, 2022 The sample code in doc about ClientAreaDomainDetailsOutput ( https://developers.whmcs.com/hooks-reference/output/#clientareadomaindetailsoutput ) seems to wrong: <?php add_hook('ClientAreaDomainDetailsOutput', 1, function($domain) { $domainName = $domain->domain; $clientModel = $domain->client; $domainStatus = $domain->status; $clientName = $clientModel->firstName . ' ' . $clientModel->lastName; return 'You can place any HTML here that will be output in the $hookOutput smarty variable array'; }); $domain is an object, not an array, and so $domainName in sample code is null ... I could convert the object in array and then parsing it, but I guess there should be a smarter way (that I don't know because I hate objects ... 😄 ) Any smart idea to retrieve domain data? 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted September 28, 2022 Share Posted September 28, 2022 Shockingly (lol) the docs are slightly wrong. The $domain is an array, that is holding a "domain" item that is then the Domain object. So it should be: <?php add_hook('ClientAreaDomainDetailsOutput', 1, function($domain) { //passed $domain might be object or might be array, lets test if (is_array($domain)) $domain = $domain['domain']; // Replace domain array with domain object $domainName = $domain->domain; $clientModel = $domain->client; $domainStatus = $domain->status; $clientName = $clientModel->firstName . ' ' . $clientModel->lastName; return 'You can place any HTML here that will be output in the $hookOutput smarty variable array'; }); Would have been quite surprised if it was indeed a domain object but maybe that is in a later version than my dev is at right now. Also, objects are great and embrace them you will. 😉 Whenever you are questioning what WHMCS is giving you, just do: logActivity("What is this junk: ".print_r($the_thing,true)); or logModuleCall("hook-hookname", 'I-did-it', "I asked for this and got", "only this short message", $processedData, $replaceVars); 1 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.