twhiting9275 Posted January 8, 2017 Share Posted January 8, 2017 "The page are not correctly routed." That is an issue with your own install, not this hook, and you'll have to work with your developers to fully implement this. From the looks of things, you're using some other sort of CMS that handles routing, and you need to address that there. The hook is quite simplistic, really. If you can't get it to work, hand it off to your developers to see why it's not working It works, I've tested it, others have as well, and verified. If it doesn't, you need to take the time and figure out why, because you're doing something different than WHMCS expects. 0 Quote Link to comment Share on other sites More sharing options...
twhiting9275 Posted January 9, 2017 Share Posted January 9, 2017 Yet another fun update for this (sorry, don't mean to keep hijacking your thread, wdele, I'll probably create a thread specifically for this, after this: Addition #1: specific grace period. So, your clients won't be immediately redirected. Change $graceperiod = "" to $graceperiod ="number" where number is the number of days to utilize it , added by request Addition #2: WHMCS System (and system ssl) URLs. was hoping to avoid this, as these actually throw two new queries into the mix, but since some don't handle redirects properly, this will help that (hopefully). <?php //redirect clients to invoice page if they are overdue. Nothing else. //provided by https://www.whmcs.guru use Illuminate\Database\Capsule\Manager as Capsule; function check_client_access($vars) { // give the client a grace period? Numeric only, as in 10, for 10 days $graceperiod = ""; //what time is it? $time = time(); //are we logged in? If not, then return $uid = $_SESSION['uid']; if (empty($uid)) { return; } //get the WHMCS system url for those systems that can't handle simple redirects $systemurl = Capsule::table('tblconfiguration')->where('setting', '=', 'SystemURL')->pluck('value'); $systemsslurl = Capsule::table('tblconfiguration')->where('setting', '=', 'SystemSSLURL')->pluck('value'); if (is_array($systemurl)) { $systemurl = $systemurl['0']; $systemsslurl = $systemsslurl['0']; } if (!empty($systemsslurl)) { $systemurl = $systemsslurl; } $filename = $vars['filename']; $displayTitle = $vars['displayTitle']; //do we have any unpaid invoices? $rows = Capsule::table('tblinvoices')->select('id') ->WHERE ('userid', '<=', $uid) ->where('status', '=', 'Unpaid') ->count(); if (empty($rows)) { //we have no unpaid invoices. Do not proceed any further return; } if (!empty($rows)) { //we have unpaid invoices. Are they overdue? foreach (Capsule::table('tblinvoices')->select('duedate') ->WHERE ('userid', '=', $uid) ->where('status', '=', 'Unpaid')->get() as $unpaidinvoice) { $invdue = $unpaidinvoice->duedate; $invdue = strtotime($invdue); if (!empty($graceperiod)) { //get the corrected date $graceperiod = $graceperiod * 24 * 60 * 60; $invdue = $invdue + $graceperiod; } if ($invdue < $time) { //let's make sure they're not viewing, or attempting to pay their invoice, ok? if ($filename !="viewinvoice" && $displayTitle != "My Invoices" && $filename !="creditcard") { //all those checks, we're finally where we need to be header('Location: clientarea.php?action=invoices'); } } } } } add_hook('ClientAreaPage', 1, "check_client_access"); 0 Quote Link to comment Share on other sites More sharing options...
system53 Posted January 9, 2017 Share Posted January 9, 2017 Yet another fun update for this (sorry, don't mean to keep hijacking your thread, wdele, I'll probably create a thread specifically for this, after this:Addition #1: specific grace period. So, your clients won't be immediately redirected. Change $graceperiod = "" to $graceperiod ="number" where number is the number of days to utilize it , added by request Addition #2: WHMCS System (and system ssl) URLs. was hoping to avoid this, as these actually throw two new queries into the mix, but since some don't handle redirects properly, this will help that (hopefully). <?php //redirect clients to invoice page if they are overdue. Nothing else. //provided by https://www.whmcs.guru use Illuminate\Database\Capsule\Manager as Capsule; function check_client_access($vars) { // give the client a grace period? Numeric only, as in 10, for 10 days $graceperiod = ""; //what time is it? $time = time(); //are we logged in? If not, then return $uid = $_SESSION['uid']; if (empty($uid)) { return; } //get the WHMCS system url for those systems that can't handle simple redirects $systemurl = Capsule::table('tblconfiguration')->where('setting', '=', 'SystemURL')->pluck('value'); $systemsslurl = Capsule::table('tblconfiguration')->where('setting', '=', 'SystemSSLURL')->pluck('value'); if (is_array($systemurl)) { $systemurl = $systemurl['0']; $systemsslurl = $systemsslurl['0']; } if (!empty($systemsslurl)) { $systemurl = $systemsslurl; } $filename = $vars['filename']; $displayTitle = $vars['displayTitle']; //do we have any unpaid invoices? $rows = Capsule::table('tblinvoices')->select('id') ->WHERE ('userid', '<=', $uid) ->where('status', '=', 'Unpaid') ->count(); if (empty($rows)) { //we have no unpaid invoices. Do not proceed any further return; } if (!empty($rows)) { //we have unpaid invoices. Are they overdue? foreach (Capsule::table('tblinvoices')->select('duedate') ->WHERE ('userid', '=', $uid) ->where('status', '=', 'Unpaid')->get() as $unpaidinvoice) { $invdue = $unpaidinvoice->duedate; $invdue = strtotime($invdue); if (!empty($graceperiod)) { //get the corrected date $graceperiod = $graceperiod * 24 * 60 * 60; $invdue = $invdue + $graceperiod; } if ($invdue < $time) { //let's make sure they're not viewing, or attempting to pay their invoice, ok? if ($filename !="viewinvoice" && $displayTitle != "My Invoices" && $filename !="creditcard") { //all those checks, we're finally where we need to be header('Location: clientarea.php?action=invoices'); } } } } } add_hook('ClientAreaPage', 1, "check_client_access"); Unfortunately we were unable to salvage somehow. We tried many different whmcs system. I don't know what I can do about this 0 Quote Link to comment Share on other sites More sharing options...
twhiting9275 Posted January 9, 2017 Share Posted January 9, 2017 This is not an issue with WHMCS, or with this addon. This is an issue with your site. Have your developers assist you with figuring this out. 0 Quote Link to comment Share on other sites More sharing options...
system53 Posted January 10, 2017 Share Posted January 10, 2017 This is not an issue with WHMCS, or with this addon. This is an issue with your site.Have your developers assist you with figuring this out. following the same process that sees a hook on the share. I tried and it works very well https://forum.whmcs.com/showthread.php?123566-Restrict-client-access-to-client-area-if-invoices-are-overdue 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.