Jump to content

hook - can not hide menu items


TGK

Recommended Posts

hi im trying hide a menu entry but i cant, i did saw somes guides like this

https://developers.whmcs.com/themes/sidebars/ 
https://whmcs.community/topic/248457-hook-can-not-hide-menu-entry/?tab=comments#comment-1155521

but still i cant :( 

im just want remove the following Menu items in client Area : "Clients Contacts" and "Client Shortcuts"

2h2eb9x.png

thanks for your help.

 

 

remov.png

Link to comment
Share on other sites

you should just need the following hook - create .php file in /includes/hooks (e.g clientsidebars.php), paste the code below into it and the sidebars should be gone the next time you refresh the page.

<?php

/**
* Remove Contacts & Shortcuts Sidebars
* @author brian!
*/

add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar)
{
	if (!is_null($secondarySidebar->getChild('Client Contacts'))) {
		$secondarySidebar->removeChild('Client Contacts');
	}
	if (!is_null($secondarySidebar->getChild('Client Shortcuts'))) {
		$secondarySidebar->removeChild('Client Shortcuts');
	}	
});

 

Link to comment
Share on other sites

4 hours ago, brian! said:

you should just need the following hook - create .php file in /includes/hooks, paste the code below into it and the sidebars should be gone the next time you refresh the page.


<?php

/**
* Remove Contacts & Shortcuts Sidebars
* @author brian!
*/

add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar)
{
	if (!is_null($secondarySidebar->getChild('Client Contacts'))) {
		$secondarySidebar->removeChild('Client Contacts');
	}
	if (!is_null($secondarySidebar->getChild('Client Shortcuts'))) {
		$secondarySidebar->removeChild('Client Shortcuts');
	}	
});

 

thanks for help i did it but when i refresh page i get error mensaje " something is wrong" i leave a screenshot

2s8i8f8.png

Link to comment
Share on other sites

<?php

/**
* Remove Contacts & Shortcuts Sidebars
* @author brian!
*/
  
use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar)
{
	if (!is_null($secondarySidebar->getChild('Client Contacts'))) {
		$secondarySidebar->removeChild('Client Contacts');
	}
	if (!is_null($secondarySidebar->getChild('Client Shortcuts'))) {
		$secondarySidebar->removeChild('Client Shortcuts');
	}	
});

 

Link to comment
Share on other sites

Sorry again now im trying to remove: that menu item " Contacts/Sub-Accounts" i tried with

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
    $primarySidebar->getChild('My Account')
        ->removeChild('Contacts/Sub-Accounts');
});

its remove fines but when i go to index.php im get this error

Oops!
Something went wrong and we couldn't process your request.

Please go back to the previous page and try again.

Error: Call to a member function removeChild() on null in /home/e8wobbakci9y/public_html/includes/hooks/removesub.php:8

i need to remove that option in PrimaryNavbar too. 

 

ill be greatful if you can help me.

 

thanks for you time.

Link to comment
Share on other sites

7 hours ago, TGK said:

i need to remove that option in PrimaryNavbar too. 

for the menu, it's not in the PrimaryNavbar, it's in the SecondaryNavbar...

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondaryNavbar', 1, function(MenuItem $secondaryNavbar)
{
	if (!is_null($secondaryNavbar->getChild('Account'))) {
		$secondaryNavbar->getChild('Account')
		->removeChild('Contacts/Sub-Accounts');
	}
});

 

Link to comment
Share on other sites

I'm having a similar situation.  This what I want to remove.  This code removes it, but I get this error.

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
    $primarySidebar->getChild('Domain Details Management')
        ->removeChild('Manage Private Nameservers');
});

 

Error: Call to a member function removeChild() on null in /home/hosti223/public_html/clients/includes/hooks/domaindetailsmanagementSidbar.php:8
Stack trace:
#0 /home/hosti223/public_html/clients/includes/hookfunctions.php(0): WHMCS\Utility\SafeInclude::{closure}(Object(WHMCS\View\Menu\Item))
#1 /home/hosti223/public_html/clients/includes/clientareafunctions.php(0): run_hook('ClientAreaPrima...', Array, true)
#2 /home/hosti223/public_html/clients/supporttickets.php(0): outputClientArea('supportticketsl...', false, Array)
#3 {main}

Link to comment
Share on other sites

untested, but try...

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
	$DomainDetails = $primarySidebar->getChild("Domain Details Management");
	if (empty($DomainDetails)) {
		return;
	}
	$DomainDetailsChildren = $DomainDetails->getChildren();
	$keysToUnset = ['Manage Private Nameservers'];
	foreach($DomainDetailsChildren as $key => $Domain_details_child) {
		if (in_array($key, $keysToUnset)) {
			$DomainDetails->removeChild($key);
		}
	}
});

 

Link to comment
Share on other sites

  • 2 years later...

My knowledge base and news section is not displaying on website end, in whmcs it is working fine, but when I tried to display it on website it shows Opps error. 

Further more i am sharing the link of my issue kindly resolve it asap, my client is disturbing. 

ERROR!!

Error: Call to a member function setLabel() on null in /home2/behosted/public_html/includes/hooks/menu.php:43
Stack trace:
#0 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Hook/Manager.php(0): WHMCS\Utility\SafeInclude::{closure}(Object(WHMCS\View\Menu\Item))
#1 /home2/behosted/public_html/vendor/illuminate/support/Facades/Facade.php(261): WHMCS\Hook\Manager->run('ClientAreaPrima...', Object(WHMCS\View\Menu\Item), false)
#2 /home2/behosted/public_html/includes/functions.php(0): Illuminate\Support\Facades\Facade::__callStatic('run', Array)
#3 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/ClientArea.php(0): run_hook('ClientAreaPrima...', Object(WHMCS\View\Menu\Item))
#4 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/ClientArea.php(0): WHMCS\ClientArea->outputWithoutExit()
#5 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Http/Message/AbstractViewableResponse.php(0): WHMCS\ClientArea->getOutputContent()
#6 /home2/behosted/public_html/vendor/middlewares/utils/src/CallableHandler.php(39): WHMCS\Http\Message\AbstractViewableResponse->getBody()
#7 /home2/behosted/public_html/vendor/middlewares/fast-route/src/FastRoute.php(96): Middlewares\Utils\CallableHandler::execute(Array, Array)
#8 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/HandleProcessor.php(0): Middlewares\FastRoute->process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#9 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/Strategy/AssumingMiddlewareTrait.php(0): WHMCS\Route\Middleware\HandleProcessor->_process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#10 /home2/behosted/public_html/vendor/middlewares/utils/src/Dispatcher.php(76): WHMCS\Route\Middleware\HandleProcessor->process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#11 [internal function]: Middlewares\Utils\Dispatcher->Middlewares\Utils\{closure}(Object(WHMCS\Http\Message\ServerRequest))
#12 /home2/behosted/public_html/vendor/middlewares/utils/src/Delegate.php(31): call_user_func(Object(Closure), Object(WHMCS\Http\Message\ServerRequest))
#13 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/AbstractProxyMiddleware.php(0): Middlewares\Utils\Delegate->process(Object(WHMCS\Http\Message\ServerRequest))
#14 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/Strategy/AssumingMiddlewareTrait.php(0): WHMCS\Route\Middleware\AbstractProxyMiddleware->_process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#15 /home2/behosted/public_html/vendor/middlewares/utils/src/Dispatcher.php(76): WHMCS\Route\Middleware\AbstractProxyMiddleware->process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#16 [internal function]: Middlewares\Utils\Dispatcher->Middlewares\Utils\{closure}(Object(WHMCS\Http\Message\ServerRequest))
#17 /home2/behosted/public_html/vendor/middlewares/utils/src/Delegate.php(31): call_user_func(Object(Closure), Object(WHMCS\Http\Message\ServerRequest))
#18 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/AbstractProxyMiddleware.php(0): Middlewares\Utils\Delegate->process(Object(WHMCS\Http\Message\ServerRequest))
#19 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/Strategy/AssumingMiddlewareTrait.php(0): WHMCS\Route\Middleware\AbstractProxyMiddleware->_process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#20 /home2/behosted/public_html/vendor/middlewares/utils/src/Dispatcher.php(76): WHMCS\Route\Middleware\AbstractProxyMiddleware->process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#21 [internal function]: Middlewares\Utils\Dispatcher->Middlewares\Utils\{closure}(Object(WHMCS\Http\Message\ServerRequest))
#22 /home2/behosted/public_html/vendor/middlewares/utils/src/Delegate.php(31): call_user_func(Object(Closure), Object(WHMCS\Http\Message\ServerRequest))
#23 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/BackendPsr7Response.php(0): Middlewares\Utils\Delegate->process(Object(WHMCS\Http\Message\ServerRequest))
#24 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/BackendPsr7Response.php(0): WHMCS\Route\Middleware\BackendPsr7Response->_process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#25 /home2/behosted/public_html/vendor/middlewares/utils/src/Dispatcher.php(76): WHMCS\Route\Middleware\BackendPsr7Response->process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#26 [internal function]: Middlewares\Utils\Dispatcher->Middlewares\Utils\{closure}(Object(WHMCS\Http\Message\ServerRequest))
#27 /home2/behosted/public_html/vendor/middlewares/utils/src/Delegate.php(31): call_user_func(Object(Closure), Object(WHMCS\Http\Message\ServerRequest))
#28 /home2/behosted/public_html/vendor/middlewares/utils/src/Dispatcher.php(56): Middlewares\Utils\Delegate->process(Object(WHMCS\Http\Message\ServerRequest))
#29 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/BackendDispatch.php(0): Middlewares\Utils\Dispatcher->dispatch(Object(WHMCS\Http\Message\ServerRequest))
#30 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/Strategy/AssumingMiddlewareTrait.php(0): WHMCS\Route\Middleware\BackendDispatch->_process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#31 /home2/behosted/public_html/vendor/middlewares/utils/src/Dispatcher.php(76): WHMCS\Route\Middleware\BackendDispatch->process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#32 [internal function]: Middlewares\Utils\Dispatcher->Middlewares\Utils\{closure}(Object(WHMCS\Http\Message\ServerRequest))
#33 /home2/behosted/public_html/vendor/middlewares/utils/src/Delegate.php(31): call_user_func(Object(Closure), Object(WHMCS\Http\Message\ServerRequest))
#34 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/RoutePathMatch.php(0): Middlewares\Utils\Delegate->process(Object(WHMCS\Http\Message\ServerRequest))
#35 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/Strategy/AssumingMiddlewareTrait.php(0): WHMCS\Route\Middleware\RoutePathMatch->_process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#36 /home2/behosted/public_html/vendor/middlewares/utils/src/Dispatcher.php(76): WHMCS\Route\Middleware\RoutePathMatch->process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#37 [internal function]: Middlewares\Utils\Dispatcher->Middlewares\Utils\{closure}(Object(WHMCS\Http\Message\ServerRequest))
#38 /home2/behosted/public_html/vendor/middlewares/utils/src/Delegate.php(31): call_user_func(Object(Closure), Object(WHMCS\Http\Message\ServerRequest))
#39 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/WhitelistFilter.php(0): Middlewares\Utils\Delegate->process(Object(WHMCS\Http\Message\ServerRequest))
#40 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/Strategy/DelegatingMiddlewareTrait.php(0): WHMCS\Route\Middleware\WhitelistFilter->_process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#41 /home2/behosted/public_html/vendor/middlewares/utils/src/Dispatcher.php(76): WHMCS\Route\Middleware\WhitelistFilter->process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#42 [internal function]: Middlewares\Utils\Dispatcher->Middlewares\Utils\{closure}(Object(WHMCS\Http\Message\ServerRequest))
#43 /home2/behosted/public_html/vendor/middlewares/utils/src/Delegate.php(31): call_user_func(Object(Closure), Object(WHMCS\Http\Message\ServerRequest))
#44 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/RoutableClientModuleRequest.php(0): Middlewares\Utils\Delegate->process(Object(WHMCS\Http\Message\ServerRequest))
#45 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/Strategy/AssumingMiddlewareTrait.php(0): WHMCS\Route\Middleware\RoutableClientModuleRequest->_process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#46 /home2/behosted/public_html/vendor/middlewares/utils/src/Dispatcher.php(76): WHMCS\Route\Middleware\RoutableClientModuleRequest->process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#47 [internal function]: Middlewares\Utils\Dispatcher->Middlewares\Utils\{closure}(Object(WHMCS\Http\Message\ServerRequest))
#48 /home2/behosted/public_html/vendor/middlewares/utils/src/Delegate.php(31): call_user_func(Object(Closure), Object(WHMCS\Http\Message\ServerRequest))
#49 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/RoutableAdminRequestUri.php(0): Middlewares\Utils\Delegate->process(Object(WHMCS\Http\Message\ServerRequest))
#50 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/Strategy/AssumingMiddlewareTrait.php(0): WHMCS\Route\Middleware\RoutableAdminRequestUri->_process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#51 /home2/behosted/public_html/vendor/middlewares/utils/src/Dispatcher.php(76): WHMCS\Route\Middleware\RoutableAdminRequestUri->process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#52 [internal function]: Middlewares\Utils\Dispatcher->Middlewares\Utils\{closure}(Object(WHMCS\Http\Message\ServerRequest))
#53 /home2/behosted/public_html/vendor/middlewares/utils/src/Delegate.php(31): call_user_func(Object(Closure), Object(WHMCS\Http\Message\ServerRequest))
#54 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/RoutableRequestUri.php(0): Middlewares\Utils\Delegate->process(Object(WHMCS\Http\Message\ServerRequest))
#55 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/Strategy/AssumingMiddlewareTrait.php(0): WHMCS\Route\Middleware\RoutableRequestUri->_process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#56 /home2/behosted/public_html/vendor/middlewares/utils/src/Dispatcher.php(76): WHMCS\Route\Middleware\RoutableRequestUri->process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#57 [internal function]: Middlewares\Utils\Dispatcher->Middlewares\Utils\{closure}(Object(WHMCS\Http\Message\ServerRequest))
#58 /home2/behosted/public_html/vendor/middlewares/utils/src/Delegate.php(31): call_user_func(Object(Closure), Object(WHMCS\Http\Message\ServerRequest))
#59 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/RoutableRequestQueryUri.php(0): Middlewares\Utils\Delegate->process(Object(WHMCS\Http\Message\ServerRequest))
#60 /home2/behosted/public_html/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/Strategy/AssumingMiddlewareTrait.php(0): WHMCS\Route\Middleware\RoutableRequestQueryUri->_process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#61 /home2/behosted/public_html/vendor/middlewares/utils/src/Dispatcher.php(76): WHMCS\Route\Middleware\RoutableRequestQueryUri->process(Object(WHMCS\Http\Message\ServerRequest), Object(Middlewares\Utils\Delegate))
#62 [internal function]: Middlewares\Utils\Dispatcher->Middlewares\Utils\{closure}(Object(WHMCS\Http\Message\ServerRequest))
#63 /home2/behosted/public_html/vendor/middlewares/utils/src/Delegate.php(31): call_user_func(Object(Closure), Object(WHMCS\Http\Message\ServerRequest))
#64 /home2/behosted/public_html/vendor/middlewares/utils/src/Dispatcher.php(56): Middlewares\Utils\Delegate->process(Object(WHMCS\Http\Message\ServerRequest))
#65 /home2/behosted/public_html/index.php(0): Middlewares\Utils\Dispatcher->dispatch(Object(WHMCS\Http\Message\ServerRequest))
#66 {main}

Website URL: https://behosted.pk/index.php/knowledgebase 

Link to comment
Share on other sites

  • 2 years later...

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