Jump to content

ClientAreaDomainDetailsOutput ....


Remitur

Recommended Posts

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?

Link to comment
Share on other sites

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);

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated