Jump to content

Hide options from domain tab


alterman

Recommended Posts

@sentq

Thanks, I've setup the following hook:

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)

{

$primarySidebar->getChild('Domains')

->removeChild('Auto Renew');

});

However, I'm getting "Ooops " error on the client are page. Could you please let me know if there anything wrong in my code?

Thanks!

Edited by WHMCS ChrisD
Added code to code box, please remember to use this in the future
Link to comment
Share on other sites

7 hours ago, alterman said:

However, I'm getting "Ooops " error on the client are page. Could you please let me know if there anything wrong in my code?

you will always need to check if the sidebar/navbar item exists before apply any changes or remove it, the following code just do that 1) check if the item we'r looking for exists then remove it:

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
if (!is_null($primarySidebar->getChild('Domains'))){
	if (is_null($primarySidebar->getChild('Domains')->getChild('Auto Renew'))){
    	$primarySidebar->getChild('Domains')->removeChild('Auto Renew');
    }
}

});

 

Link to comment
Share on other sites

@sentq

Thanks, I've modified it a bit and it works like a charm. I hope someone finds it useful:

 

<?php

use WHMCS\View\Menu\Item as MenuItem;



add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
        if (!is_null($primarySidebar->getChild('Domain Details Management'))) {
                $primarySidebar->getChild('Domain Details Management')
                        ->removeChild('Auto Renew Settings')
                        ->removeChild('Registrar Lock Status')
                        ->removeChild('Domain Addons')
                        ->removeChild('Domain Contacts')
                        ->removeChild('Manage Private Nameservers');
        }
});

 

Link to comment
Share on other sites

any of the child items could be removed by other hook causing 500 error, we need to check if each of the child items exists before remove :)

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
  if (!is_null($primarySidebar->getChild('Domain Details Management'))) {
    if (!is_null($primarySidebar->getChild('Domain Details Management')->getChild('Auto Renew Settings'))){
      $primarySidebar->getChild('Domain Details Management')->removeChild('Auto Renew Settings');
    }
    if (!is_null($primarySidebar->getChild('Domain Details Management')->getChild('Registrar Lock Status'))){
      $primarySidebar->getChild('Domain Details Management')->removeChild('Registrar Lock Status');
    }
    if (!is_null($primarySidebar->getChild('Domain Details Management')->getChild('Domain Addons'))){
      $primarySidebar->getChild('Domain Details Management')->removeChild('Domain Addons');
    }
    if (!is_null($primarySidebar->getChild('Domain Details Management')->getChild('Domain Contacts'))){
      $primarySidebar->getChild('Domain Details Management')->removeChild('Domain Contacts');
    }
    if (!is_null($primarySidebar->getChild('Domain Details Management')->getChild('Manage Private Nameservers'))){
      $primarySidebar->getChild('Domain Details Management')->removeChild('Manage Private Nameservers');
    }
      
  }
});

 

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