DigiSA Posted March 31, 2016 Share Posted March 31, 2016 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! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 31, 2016 Share Posted March 31, 2016 (edited) 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 March 31, 2016 by brian! 0 Quote Link to comment Share on other sites More sharing options...
DigiSA Posted March 31, 2016 Author Share Posted March 31, 2016 Ah yes, sorry! It is indeed a sub-account. Thanks I will try out your methods, and hopefully come back with some positive news. 0 Quote Link to comment Share on other sites More sharing options...
DigiSA Posted April 1, 2016 Author Share Posted April 1, 2016 Okay Double 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.