Jump to content
dosrox

Remove Store dropdown menu

Recommended Posts

Hi, 

 

I've looked all over the forums and came across alot of hooks to remove certain menu items and they worked just fine.
However, i want to remove my store drop down menu entirely. 

Is there someone that can help me with the hook? 

I've tried this so far: 

add_hook('ClientAreaNavbars', -1, function () {
    $primaryNavbar = Menu::primaryNavbar();
    $secondaryNavbar = Menu::secondaryNavbar();
    
    //remove child from primary navbar
    if ($primaryNavbar && !is_null($primaryNavbar->getChild('Store.php'))) {
        $primaryNavbar->removeChild('Store.php');
    }

Thanks in advance.

Share this post


Link to post
Share on other sites
22 hours ago, dosrox said:

However, i want to remove my store drop down menu entirely.
Is there someone that can help me with the hook? 

you can use the following hook to remove the Store menu dropdown...

<?php

# Remove Store From Navbar Hook
# Written by brian!

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
	if (!is_null($primaryNavbar->getChild('Store'))) {
            $primaryNavbar->removeChild('Store');
	}
});
  • Like 1

Share this post


Link to post
Share on other sites

Thanks Brian, I did this before however, i think it was a cookie related error on chrome.

Sorry!

Share this post


Link to post
Share on other sites

Is there a way i can hide the dropdown menu's created on the nav bar when you're logged in?

I basically want to use the navigation menu for logged out users and logged in users to be the same.

 

Thanks in advance!

Share this post


Link to post
Share on other sites
On 07/03/2019 at 11:34, dosrox said:

Is there a way i can hide the dropdown menu's created on the nav bar when you're logged in?

just me in particular? lol

On 07/03/2019 at 11:34, dosrox said:

I basically want to use the navigation menu for logged out users and logged in users to be the same.

are you saying that you want users when they're logged in to still see...

hGkDYHw.png

and not...?

hPJnp12.png

if so, then you would need a primary navbar hook to delete those menus if the client is logged in, and then recreate the "loggedout" menu items... with an optional secondary navbar hook if you want to do something similar on the "Account" side of the menu.

  • Like 1

Share this post


Link to post
Share on other sites

You're welcome anytime! haha

Basically i made a custom menu bar with hooks: Home Updates Contact Domainnames Webhosting Support.
When users log in it adds the dropdown menu's you posted above.

I just want to remove these drop down menu's: Service's, Domains, Billing, and Support.

Sorry for my lack of knowledge, very new to whmcs!

Thanks for the help!
 

Share this post


Link to post
Share on other sites

If someone can help me make a hook for hiding these dropdown menu's: Service's, Domains, Billing and support that would really help me out!

Share this post


Link to post
Share on other sites
On 08/03/2019 at 13:13, dosrox said:

Basically i made a custom menu bar with hooks: Home Updates Contact Domainnames Webhosting Support.

and you want the user to see this custom menu whether they're logged in or not? if so, post your hook code - no point in me reinventing the wheel when you've done half the work! 🙂

  • Like 1

Share this post


Link to post
Share on other sites

Right now when your not logged in users see this: https://gyazo.com/8357cd854222fb547973b57cefaf6a6e
when they are you see this: https://gyazo.com/9f96365771a7c78c8a7f015abccaa138
From the second screenshot i want to remove the dropdown menu's ( Service's, Domains, Billing and support )

I have made this menu with several hooks you posted on the forums before.

If possible, i'll make a new hook to remove these items for the logged in menu thats all i need.

 

Share this post


Link to post
Share on other sites
20 hours ago, dosrox said:

I have made this menu with several hooks you posted on the forums before.

that's the bit I was afraid of - multiple hooks all interacting with the menu at the same time... and is why I asked you to post the hook code that you had used because while it's simple for me to post the code that would remove these menus, i'm reluctant to do it for fear of causing issues down the road (e.g one hook adding menus, another hook removing them and me not knowing the order that they're running)...

but to remove those 4 items from the menu, you should just need to use the hook below...

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
	$client = Menu::context('client'); 
	if (!is_null($client) && !is_null($primaryNavbar->getChild('Services'))) {
				$primaryNavbar->removeChild('Services');
	}
	if (!is_null($client) && !is_null($primaryNavbar->getChild('Domains'))) {
				$primaryNavbar->removeChild('Domains');
	}
	if (!is_null($client) && !is_null($primaryNavbar->getChild('Billing'))) {
				$primaryNavbar->removeChild('Billing');
	}
	if (!is_null($client) && !is_null($primaryNavbar->getChild('Support'))) {
				$primaryNavbar->removeChild('Support');
	}
});

there are neater ways to do it, but i've tried to keep it simple to avoid issues - at some point, you really should consolidate those hooks that are modifying the navbar into just one hook.

  • Like 1

Share this post


Link to post
Share on other sites

Ah, i'm sorry i have alot of "small" hooks so i thought i wouldn't soam you with all the code.

Hooks are new to me as i said and i'll try yours right now i think this is exactly what i need!

Thanks for the help so far brian, apparently my posts have to be approved first so sorry for the spam!

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated