monsterit Posted October 20, 2018 Share Posted October 20, 2018 Hi All, I'm hoping you can help. I've trawled through pages upon pages of documents, community's etc to try and find an answer but I cant find one. Is it possible to restrict our knowledge base page to logged in users only or force them to login? I found this script in a previous post but it redirects all pages to the login page. (which is not good for new/potential customers. <?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")) && $clientID===0){ header("Location: login.php"); exit; } } } add_hook("ClientAreaPage", 1, "hook_ForceEveryoneToLogin"); Is there something possible i can do to this script to only change it to restrict the knowledge base page? 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted October 20, 2018 Share Posted October 20, 2018 (edited) <?php function hook_ForceEveryoneToLogin($vars) { if (!$vars['loggedin'] AND (in_array($vars['templatefile'], array('knowledgebase', 'knowledgebasearticle', 'knowledgebasecat')))) { header('Location: login.php'); die(); } } add_hook("ClientAreaPage", 1, "hook_ForceEveryoneToLogin"); Edited October 20, 2018 by Kian 0 Quote Link to comment Share on other sites More sharing options...
monsterit Posted October 21, 2018 Author Share Posted October 21, 2018 perfect thank you 🙂 0 Quote Link to comment Share on other sites More sharing options...
wp4all Posted October 31, 2018 Share Posted October 31, 2018 Hi , this hook is checking about the template file but how would it bee if it is an new *.php site. For example .. /whmcs/mynewsite.php ? Thanks and best regards Christian 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted October 31, 2018 Share Posted October 31, 2018 It's not a problem. I suppose that you are talking about custom PHP files created for WHMCS (Creating Pages). In these files you can directly use: $ca->requireLogin(); To require login. 1 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.