Jump to content

Restrict page content to active customers


charlieroot

Recommended Posts

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

Link to comment
Share on other sites

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}

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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