Jump to content

smarty variable - Hide elements if sub account is logged in?


DigiSA

Recommended Posts

Hi there guys,

 

I need some help :)

 

I am trying to hide menu items based on sub clients being logged in, so basically the below code but for sub clients.

 

{if $loggedin}
   <p>User is logged in so display client only information</p>
{else}
   <p>User is not logged in so display this</p>
{/if}

 

I know there is no native variable for sub clients, and I would have to create a hook for that, but I can't seem to find any assistance on google or WHMCS docs. I have found the below code, and was wondering if anyone could guide me in the right direction.

 

<?php
/**
* Hook sample for defining additional template variables
*
* @param array $vars Existing defined template variables
*
* @return array
*/
function hook_template_variables_example($vars)
{
   $extraTemplateVariables = array();

   // set a fixed value
   $extraTemplateVariables['fixedValue'] = 'abc';

   // fetch clients data if available
   $clientsData = isset($vars['clientsdetails']) ? $vars['clientsdetails'] : null;

   // determine if client is logged in
   if (is_array($clientsData) && isset($clientsData['id'])) {
       $userId = $clientsData['id'];
       // perform calculation here
       $extraTemplateVariables['userSpecificValue'] = '123';
       $extraTemplateVariables['anotherUserOnlyValue'] = '456';
   }

   // return array of template variables to define
   return $extraTemplateVariables;
}

add_hook('ClientAreaPageViewTicket', 1, 'hook_template_variables_example');
?>

 

Thanks a ton!

Link to comment
Share on other sites

when you say "sub-clients", do you mean "sub-accounts" ? :?:

 

http://docs.whmcs.com/Sub-Accounts

 

if so, and if you're using a template based on "Six", then you should probably take a look at the WHMCS Class Documentation.

 

http://docs.whmcs.com/classes/classes/WHMCS.User.Client.Contact.html

 

that has a variable that you can use in your navbar/sidebars etc which can check for sub-account status - $isSubAccount

 

Whether or not a client contact is a sub-account. Sub-accounts may log into the client area.

reading the documentation/cheatsheets on v6 navigation might also help...

 

http://docs.whmcs.com/Version_6.0

 

no-one has asked about this before, so you're in unknown waters - the above documentation is all we have to go on... try it on something simple first such as adding or removing a menu item..

Edited by brian!
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