charlieroot Posted November 5, 2014 Share Posted November 5, 2014 Hello, Is there any way using template syntax to restrict pages or page content (eg., paragraphs) so that only customers with an active service/product would see? thanks in advance 0 Quote Link to comment Share on other sites More sharing options...
Cain72 Posted November 6, 2014 Share Posted November 6, 2014 Hi charlieroot, with my humble hackish knowledge of the monster, i would be looking through the docs on how to work the hooks, Then you should be able to dig into a {$loggedin} client and check if they have active products .. from there just wrap your code around the HTML you want to hide or show based on the results of the hooks for a logged in client .. http://docs.whmcs.com/Hooks i dont know if that helps but that would be an angle of attack if i was working on this. Cain 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted November 6, 2014 Share Posted November 6, 2014 in Smarty .tpl files: {if $loggedin} // Put your private content here, this content will appear to loggedin clients only {/if} {if ($loggedin==true && $clientsstats.productsnumtotal>0)} // This content will displayed to loggedin clients with at least one product in their account {/if} 0 Quote Link to comment Share on other sites More sharing options...
Cain72 Posted November 6, 2014 Share Posted November 6, 2014 Or you could do that !! much more elegant than my lumberjack approach Cain 0 Quote Link to comment Share on other sites More sharing options...
charlieroot Posted November 7, 2014 Author Share Posted November 7, 2014 thank you guys for the replies. Sentq, that looks exactly like what I was looking for! Got to give it a try tomorrow. Thanks again - - - Updated - - - one quick question before I test. I only want to do that for a single or a few pages. What's the most elegant way to do it? I was thinking of a conditional mix between the code above and if page title is [whatever] but doesn't seem too elegant tbh 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted November 8, 2014 Share Posted November 8, 2014 the snippet code i wrote above can be used in any smarty files (example-file-name.tpl) so if you need to hide content from the public visitors in Affiliates page you would need to modify "WHMCS/templates/yourTemplate/affiliates.tpl" and add the content you need to hide inside one of the conditions above.. i hope this can help you 0 Quote Link to comment Share on other sites More sharing options...
charlieroot Posted November 8, 2014 Author Share Posted November 8, 2014 thanks, but what if my intention is to restrict a paragraph only on two knowledge-base articles? 0 Quote Link to comment Share on other sites More sharing options...
charlieroot Posted November 10, 2014 Author Share Posted November 10, 2014 so is it possible in any way to do it only in some knowledgebase article? it doesn't help if it applies to the whole template because it is only an article which I want to add the restriction to. thanks again for your help 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted November 10, 2014 Share Posted November 10, 2014 you can use the following action hook (tested), it'll redirect visitors to login screen for the specified articles, create file inside " WHMCS/includes/hooks " name it forceloginkb.php for example, and put the following code inside it: <?php /* * Use This Hook action to prevent public access to some specified knowledge-base articles **/ function hook_forceLoginToKnowledgebase($vars) { # Add Article IDs you need to force login to be displayed, separate by comma $blockedIDs = array(2,4); $clientid = intval($_SESSION['uid']); $articleID = intval($_GET['id']); $action = trim($_GET['action']); if ($vars['filename']=='knowledgebase' && $action=='displayarticle'){ if (in_array($articleID, $blockedIDs) && $clientid=='0'){ header("Location: login.php"); exit; } } } add_hook("ClientAreaPage", 1, "hook_forceLoginToKnowledgebase"); ?> in line #8 you can specify all articles ids you need your visitors/clients to be logged in to see it, try it 0 Quote Link to comment Share on other sites More sharing options...
charlieroot Posted November 10, 2014 Author Share Posted November 10, 2014 thanks a lot! Will try it. In the meantime I also sent you an email (through your website). 0 Quote Link to comment Share on other sites More sharing options...
mbit Posted November 10, 2014 Share Posted November 10, 2014 Is it not easier to simply mark the KB article private? 0 Quote Link to comment Share on other sites More sharing options...
charlieroot Posted November 10, 2014 Author Share Posted November 10, 2014 Is it not easier to simply mark the KB article private? No. The information posted in some specific articles is dynamic and should be available only to active customers. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 11, 2014 Share Posted November 11, 2014 http://docs.whmcs.com/Support_Center#Knowledgebase Ticking the Private checkbox will mean this article is not visible to visitors so clients must be logged in to read it. 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.