jeffmchristensen Posted November 29, 2017 Share Posted November 29, 2017 We are trying to restrict access to Knowledgebase page to only users that are logged in. How is this possible through WHMCS hooks or is .htaccess a better method to use? What would be the code used to implement this control. Link to comment Share on other sites More sharing options...
brian! Posted November 30, 2017 Share Posted November 30, 2017 you can make articles private so that only logged in users can read them... https://docs.whmcs.com/Support_Center#Knowledgebase Quote Ticking the Private checkbox will mean this article is not visible to visitors so clients must be logged in to read it. or do you want to go further than that ? Link to comment Share on other sites More sharing options...
jeffmchristensen Posted November 30, 2017 Author Share Posted November 30, 2017 Yes but I found this hook and implemented it. <?php if (!defined("WHMCS")) die("This file cannot be accessed directly"); function hook_ForceEveryoneToLogin($vars) { $clientID = intval($_SESSION['uid']); $adminID = intval($_SESSION['adminid']); if ($adminID===0){ if (!in_array($vars['filename'], array("login","dologin","clientarea","pwreset", "register", "index", "submitticket")) && $clientID===0){ header("Location: register.php"); exit; } } } add_hook("ClientAreaPage", 1, "hook_ForceEveryoneToLogin"); It will redirect all pages to the login page excluding the "filename" array. Thanks Link to comment Share on other sites More sharing options...
brian! Posted December 1, 2017 Share Posted December 1, 2017 15 hours ago, jeffmchristensen said: Yes but I found this hook and implemented it. for the benefit of others, this is a hook written by @sentq and posted in the thread below... Link to comment Share on other sites More sharing options...
Recommended Posts