Jump to content

Client nav bar


Recommended Posts

I am trying to add a link under the Account section on the client nav bar (creating a hook). This link will only be displayed when users are logged in as only users will have access to this account function.

 

Here is the code I have so far, but the link is NOT being displayed..

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondaryNavbar', 1, function (MenuItem $secondaryNavbar)
{
if (!is_null($secondaryNavbar->getChild('Account'))) {
if (!is_null($client)) {
$secondaryNavbar->getChild('Account')
->addChild('Manage Subscriptions', array(
'label' => 'Manage Subscriptions',
'uri' => '{$whmcs_subscriptions_url}',
'order' => '100',
));
}}
});

 

Any ideas ??

Edited by AffordableDomainsCanada
Link to comment
Share on other sites

<?php

 

use WHMCS\View\Menu\Item as MenuItem;

 

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

{

 

$_SESSION['uid'] = intval($_SESSION['uid']);

 

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

if ($_SESSION['uid']!='') {

$secondaryNavbar->getChild('Account')

->addChild('Manage Subscriptions', array(

'label' => 'Manage Subscriptions',

'uri' => '{$whmcs_subscriptions_url}',

'order' => '100',

));

}}

});

Link to comment
Share on other sites

I got that code to work, the only problem is...

 

'uri' => '{$whmcs_subscriptions_url}', 3

 

is supposed to redirect to --->

 

http://www.affordabledomains.ca/index.php?m=whmcs_subscriptions&id=9&token=410fee786fe1180da21aa11b5e3830d0

 

but when I tried adding

 

/index.php?m=whmcs_subscriptions

 

it just redirects me to the home page, it doesnt take me to /index.php?m=whmcs_subscriptions

 

Any ideas on how I can change that ??

Link to comment
Share on other sites

you need to specify "id" parameter in this URL: index.php?m=whmcs_subscriptions&id=xx

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondaryNavbar', 1, function (MenuItem $secondaryNavbar)
{
global $CONFIG;
$_SESSION['uid'] = intval($_SESSION['uid']);

if (!is_null($secondaryNavbar->getChild('Account'))) {
   if ($_SESSION['uid']!='0') {
       $secondaryNavbar->getChild('Account')
       ->addChild('Manage Subscriptions', array(
       'label' => 'Manage Subscriptions',
       'uri' => $CONFIG['SystemURL'].'/index.php?m=whmcs_subscriptions&id=xx',
       'order' => '100',
       ));
   }
}
});

Link to comment
Share on other sites

Will that id parameter be different for every user ? How and where do I get this id ??

 

I set the link up else where and when I visit the link my client id is 9, and there is also a token parameter..

 

Im sorry for asking so many times, but im not exactly sure what I am supposed to do, I put the code in the hooks folder and the link is coming up with the xx displayed in my url.

Link to comment
Share on other sites

yes it is an addon module from No Half Pixels. I contacted the author to get help creating the link in the client nav menu, but he directed me here to ask for help from WHMCS. Very poor support, especially when you have to pay for extended support and updates.

 

Is there anyway when the user is logged in the id parameter is filled in ?

 

Is that id number associated with a users account? There for every user will have a different id # ??

Link to comment
Share on other sites

Is there anyway when the user is logged in the id parameter is filled in ?

 

Is that id number associated with a users account? There for every user will have a different id # ??

does it have DB tables? can you take screenshot from this tables structures? it will help to know if the ID comes from DB or client ID is the one used.

Link to comment
Share on other sites

if it use client ID so it should look like

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondaryNavbar', 1, function (MenuItem $secondaryNavbar)
{
global $CONFIG;
$_SESSION['uid'] = intval($_SESSION['uid']);

if (!is_null($secondaryNavbar->getChild('Account'))) {
   if ($_SESSION['uid']!='0') {
       $secondaryNavbar->getChild('Account')
       ->addChild('Manage Subscriptions', array(
       'label' => 'Manage Subscriptions',
       'uri' => $CONFIG['SystemURL'].'/index.php?m=whmcs_subscriptions&id='.$_SESSION['uid'],
       'order' => '100',
       ));
   }
}
});

Link to comment
Share on other sites

your a genius! That worked, somewhat. Now I setup that link else where and this is where it takes me to.

 

http://www.affordabledomains.ca/index.php?m=whmcs_subscriptions&id=9&token=410fee786fe1180da21aa11b5e3830d0'>http://www.affordabledomains.ca/index.php?m=whmcs_subscriptions&id=9&token=410fee786fe1180da21aa11b5e3830d0

 

so we have the id figured out, but there also needs to be a token, when I click on the link from the script you provided me, I get

 

http://www.affordabledomains.ca/index.php?m=whmcs_subscriptions&id=9

 

There is NO token provided, how can we add a token ?

Link to comment
Share on other sites

you don't need $token variable when you use GET method it's only need when you submit form, but here is how we can get it

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondaryNavbar', 1, function (MenuItem $secondaryNavbar)
{
global $CONFIG;
global $smarty;
$_SESSION['uid'] = intval($_SESSION['uid']);

if (!is_null($secondaryNavbar->getChild('Account'))) {
   if ($_SESSION['uid']!='0') {
       $secondaryNavbar->getChild('Account')
       ->addChild('Manage Subscriptions', array(
       'label' => 'Manage Subscriptions',
       'uri' => $CONFIG['SystemURL'].'/index.php?m=whmcs_subscriptions&id='.$_SESSION['uid'].'&token='.$smarty->get_template_vars('token'),
       'order' => '100',
       ));
   }
}
});

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