Jump to content

ClientLogin hook, how to deny login if Inactive


slig

Recommended Posts

Hi, I'm trying to figure out how hooks work based on the (limited) documentation and it doesn't seem to work as expected. Does WHMCS have decisional logic around the hooks or are they just intended to perform some action, with whmcs continuing thereafter regardless of outcome?

 

I had a look at vatnumbervalidation.php, which sets $errormessage but this doesn't look to ever be used. Ideally I'm trying to intercept a client login attempt and redirect them to an external page if they are marked as 'inactive'. At this stage though I'd be happy with just a simple error message!

 

<?php

function loginDisabled($vars) {
       global $errormessage;

       if (!empty($vars['userid'])) {
               $rs = select_query("tblclients","id",array("status"=>"inactive","id"=>$vars['userid']));
               $data = mysql_fetch_assoc($rs);
               if (is_array($data) && ($data['id'] == $vars['userid'])) {
                       $errormessage  .= "<li>Logins disabled</li>";
                       return FALSE;
               }
       }
       return TRUE;
}

add_hook('ClientLogin', 0, 'loginDisabled');

 

docs mention neither the globals I can pick up (like errormessage for example), or whether bool's can be returned and acted upon.

 

ps: yes, I know 'closed' status denies logins, but closed status' can keep working as they are.

 

anyone know what gives? thanks! :D

Edited by slig
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated