Jump to content

Trying to add a link to the account section menu


Recommended Posts

Charley,

 

it's going to be something along the lines of...

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondaryNavbar', 1, function (MenuItem $secondaryNavbar)
{
   if (!is_null($secondaryNavbar->getChild('Account'))) {
       $secondaryNavbar->getChild('Account')
       ->addChild('brian', array(
                   'label' => 'Label Name',
                   'uri' => 'http://www.google.com',
                   'order' => 40,
   ));
   }
});

you might need to change a few things - e.g the label name... and the child name (if you don't want to name it after me!). :-P

 

give it a .php filename, stick it in /includes/hooks and it should work.

Link to comment
Share on other sites

Hmm, I added the file Affiliates.php

 

With this code but no luck, these hooks are the death of me. I can seem to wrap my head around the formats:

 

<?php

 

 

use WHMCS\View\Menu\Item as MenuItem;

 

 

add_hook('ClientAreaSecondaryNavbar', 1, function (MenuItem $secondaryNavbar)

{

if (!is_null($secondaryNavbar->getChild('Account'))) {

$secondaryNavbar->getChild('Account')

->addChild('affiliates', array(

'label' => 'Affiliates',

'uri' => 'affiliates.php',

'order' => 40,

));

}

});

Link to comment
Share on other sites

the code itself is fine - this is what the above hook does on my v7.1.2 dev....

 

QBQtPfm.png

 

whereas, if you look at your site using the Six template, I see this...

 

Bh9sJXB.png

 

that icon next to account, plus the cart being there immediately tells me that the secondary navbar is already being modified by a hook - probably the mysterious "TMSecondaryNavbar.php" - perhaps there's a clash with whatever that hook is doing and what the above hook is doing.

 

I can see there is already an Affiliates link in your primary navbar, and you can't have two children with the same name (not label) in the same navbar - but as these are different navbars, that shouldn't matter.

 

if I were you, i'd consolidate the navbar hooks all in one file (or 2 if you want to split them primary/secondary) - that way you only need to look in one place for changes to the navbar... if you've got multiple hooks trying to do different things to the same navbar, and if one isn't coded correctly, then you'll see errors (or more likely a blank screen!).

Link to comment
Share on other sites

  • 3 years later...

Good day all

I have noticed that the following code works to activate affiliates:

<?php

 

 

use WHMCS\View\Menu\Item as MenuItem;

 

 

add_hook('ClientAreaSecondaryNavbar', 1, function (MenuItem $secondaryNavbar)

{

if (!is_null($secondaryNavbar->getChild('Account'))) {

$secondaryNavbar->getChild('Account')

->addChild('affiliates', array(

'label' => 'Affiliates',

'uri' => 'affiliates.php',

'order' => 40,

));

}

});

 

The only problem I have is to have this done for a specific individual who is already an activated affiliate in my WHMCS Dashboard.

Can someone please explain to me how to get this activated for a specific affiliate ?

Thank you in advanced

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.

×
×
  • 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