Jump to content

Editing the navbar to remove / redirect items


Infused-Hosting

Recommended Posts

Hi,

I am trying to remove / edit the navbar items on our WHMCS installation. So far when not logged in, I've used a hook to redirect store menu links to the appropriate page on our main website.
I'm now trying to edit the navbar once signed in by either

A) Redirect "Order new services" to the main website
OR
B) Remove "Order new servers" completely from the dropdown.

Reason being, I don't want customers being able to access the cart.php file unless processing an order. I've already enabled the redirect home to login page to reduce the chance of accessing the order cart manually.

Our navbar also shows "Chat Now" but we dont have the live chat function installed. I tried the following hook in a new file but doesnt seem to work

 

<?php


use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
    if (!is_null($primaryNavbar->getChild('Chat Now'))) {
        $primaryNavbar->removeChild('Chat Now');
    }
});

 

Thanks
Alec

Link to comment
Share on other sites

Edit sorry I am using the following hook to redirect store menu items to various pages. It was working but now has randomly stopped working. This is the code:

<?php

# Change Store Navbar Links Hook
# Written by brian!

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function(MenuItem $primaryNavbar)
{
	$Store = $primaryNavbar->getChild("Store");
	if (empty($Store)) {
		return;
	}
	$StoreChildren = $Store->getChildren();
	$kidslinks = array("Website Hosting", "Reseller Hosting", "Virtual Servers", "Dedicated Servers", "VPN",);
	foreach($StoreChildren as $key => $Store_details_child) {
		if (in_array($key, $kidslinks)) {
			if ($key === "Website Hosting"){$newlink = "https://infusedhosting.co.uk/website-hosting/";}
			elseif ($key === "Reseller Hosting"){$newlink = "https://infusedhosting.co.uk/reseller-hosting/";}
			elseif ($key === "Virtual Servers"){$newlink = "https://infusedhosting.co.uk/virtual-servers/";}
			elseif ($key === "Dedicated Servers"){$newlink = "https://infusedhosting.co.uk/dedicated-servers/";}
			elseif ($key === "VPN"){$newlink = "https://infusedhosting.co.uk/vpn/";}
	

		}
	}
});

 

Link to comment
Share on other sites

22 hours ago, Infused-Hosting said:

Edit sorry I am using the following hook to redirect store menu items to various pages. It was working but now has randomly stopped working.

I think the clue is the big space with no code after the last elseif - take a look at the original hook in the thread below... you're basically missing the line that changes the link.

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