Jump to content

Client Area Sidebar - Error


Qhiliqq

Recommended Posts

Hi,

I created a new hook, which should add the username of the user to Client Details sidebar.
Yes usernames, I got an extra module for that.

My php look like this:

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
	$specialTXT = <<<EOT
	Test
EOT;
	
	$primarySidebar->getChild("Client Details")->setBodyHtml($specialTXT);
});

But now my whole "nonuser" Website stops working...
Error in logs:

[Sun Feb 25 17:12:30.531758 2018] [:error] [pid 29143] [client xxx.xxx.249.xxx:62288] [WHMCS Application] ERROR: exception 'Whoops\\Exception\\ErrorException' with message 'Call to a member function setBodyHtml() on null' in /xxx/includes/hooks/ClientAreaSidebar.php:8 Stack trace: #0 /xxx/vendor/whmcs/whmcs-foundation/lib/Utility/Error/Run.php(0): WHMCS\\Utility\\Error\\Run->handleError(1, 'Call to a membe...', '/xxx...', 8) #1 [internal function]: WHMCS\\Utility\\Error\\Run->handleShutdown() #2 {main} {"exception":"[object] (Whoops\\\\Exception\\\\ErrorException(code: 1): Call to a member function setBodyHtml() on null at /xxx/includes/hooks/ClientAreaSidebar.php:8)"} []

Also I just want to add something and not change the whole field...

Regards :)
 

Link to comment
Share on other sites

6 hours ago, DAThosting said:

But now my whole "nonuser" Website stops working...

the golden rule with sidebar/navbar hooks is that you HAVE to check that the item exists before you try to change/remove it - so you're hook would work fine on the client's homepage (because the sidebar exists), but on any other page, it won't exist and therefore you're trying to modify something that isn't there.

6 hours ago, DAThosting said:

Also I just want to add something and not change the whole field...

take a look at the hook below - that might be a better starting point for you. :idea:

then it's just a case of working out how to get the usernames - which I guess will either be a custom field, or in a database table somewhere.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • 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