Jump to content

Modifying sidebar links


Trax

Recommended Posts

Hey, i am trying to remove the "Login to cPanel" and "Login to webmail" links.

 

I have managed to remove them with this code

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
   $primarySidebar->getChild('Service Details Actions')
       ->removeChild('Login to cPanel')
       ->removeChild('Login to Webmail')
       ->removeChild('Change Password');
});

 

Only issue is, when i now go to /clientarea.php?action=services i get a error 500 page?

 

Any ideas why?

Link to comment
Share on other sites

you should use the is_null function always to avoid error 500

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
   if (!is_null($primarySidebar->getChild('Service Details Actions'))){
       $servicesDetails = $primarySidebar->getChild('Service Details Actions');
       if (!is_null($servicesDetails->removeChild('Login to cPanel'))){
           $servicesDetails->removeChild('Login to cPanel');
       }
       if (!is_null($servicesDetails->removeChild('Login to Webmail'))){
           $servicesDetails->removeChild('Login to Webmail');
       }
       if (!is_null($servicesDetails->removeChild('Change Password'))){
           $servicesDetails->removeChild('Change Password');
       }
   }
});

Edited by sentq
Link to comment
Share on other sites

If you turn on display errors (admin -> setup -> general settings -> other), then reapply the code, what's the error shown?

 

<edit>

Make sure you turn them back off after you're done

 

Parse error: syntax error, unexpected '{' in /home/xxxxxxxx/public_html/includes/hooks/side-menus.php on line 7

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