Jump to content

Hook to add link to client nav bar under Your Account


Recommended Posts

I am trying to add a Manage Subscriptions link under the Account nav bar, here is the hook so far but I am having some issues with the uri

 

 <?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',
       ));
   }
}
}); 

 

 

When I click on the link, it redirects to the right page but I get this error.

 

Whoops! There seems to be a problem with the authentication token, please login to your clientarea to manage your subscriptions

 

I found this in the module folder itself in the hook.php file I dont know if someone can use it to help me?

 

    $merge_fields['whmcs_subscriptions_link'] = '<a href="'.$CONFIG['SystemURL'].'/index.php?m=whmcs_subscriptions&id='.$clientid.'&token='.md5(ROOTDIR.$clientid).'">Manage Subscriptions</a>';
   $merge_fields['whmcs_subscriptions_url'] = $CONFIG['SystemURL'].'/index.php?m=whmcs_subscriptions&id='.$clientid.'&token='.md5(ROOTDIR.$clientid);

Link to comment
Share on other sites

normally, i'd have said go back to the original module author for help with a 3rd-party addon (though this addon is no longer mentioned on his site anyway)... but going from previous threads, I know he's gone AWOL. :roll:

 

going from the code you posted from the hook.php file, which refers to the email templates, you might want to try the following and see if it works...

 

<?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'].'&token='.md5($_SESSION['uid']),
       'order' => '100',
       ));
   }
}
});

Link to comment
Share on other sites

No that didnt work..

 

Whoops! There seems to be a problem with the authentication token, please login to your clientarea to manage your subscriptions

 

It is weird cause I can use something like this in a tpl file

<a href="{$whmcs_subscriptions_url}">test</a>

 

and can use {$whmcs_subscriptions_url} in email templates but I cant add a link to the nav bar using {$whmcs_subscriptions_url}

Link to comment
Share on other sites

what about that:

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondaryNavbar', 1, function (MenuItem $secondaryNavbar)
{
global $CONFIG;

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='.md5(ROOTDIR.$_SESSION['uid']),
       'order' => '100',
       ));
   }
}
});

Link to comment
Share on other sites

Yes that works! Is there any way of making it so it is only displayed to logged in users ? Its displaying even when logged out

change it to:

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondaryNavbar', 1, function (MenuItem $secondaryNavbar)
{
global $CONFIG;

if (!is_null($secondaryNavbar->getChild('Account')) && $_SESSION['uid']) {
       $secondaryNavbar->getChild('Account')
       ->addChild('Manage Subscriptions', array(
       'label' => 'Manage Subscriptions',
       'uri' => $CONFIG['SystemURL'].'/index.php?m=whmcs_subscriptions&id='.$_SESSION['uid'].'&token='.md5(ROOTDIR.$_SESSION['uid']),
       '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