monsterit Posted July 9, 2018 Share Posted July 9, 2018 Hi All, I was wondering if it was possible for me to create a page for promotions for my customers. For instance all my customers are willing to give discount etc for other customers. I was wondering if i can set a page just for logged in clients to view what promotions/offers are available? Is this possible or am i barking up the wrong tree. 0 Quote Link to comment Share on other sites More sharing options...
Vox Posted July 9, 2018 Share Posted July 9, 2018 Hi monsterit, 47 minutes ago, monsterit said: I was wondering if i can set a page just for logged in clients to view what promotions/offers are available? Yes, just use the method here: https://developers.whmcs.com/advanced/creating-pages/ It already has the code block available to restrict the view to users who are logged in. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 9, 2018 Share Posted July 9, 2018 to expand on @Vox reply, you could do this in the .php file... if ($ca->isLoggedIn()) { $ca->setTemplate('clientareahome'); } else { $ca->setTemplate('homepage'); } $ca->output(); so logged in users would see clientareahome, anyone not logged in would see homepage... obviously, you wouldn't use these two templates, but you get the idea. alternatively, you could point to just one template and let the template handle what to do whether they're logged in or not. btw - if you were feeling lazy and didn't want to use a new custom page, another way might be to make a kb article and mark it private - only logged in clients would be able to read it... and you could link to it directly if required. 0 Quote Link to comment Share on other sites More sharing options...
monsterit Posted July 10, 2018 Author Share Posted July 10, 2018 Ok, so if i did a standard php page that would work, but what hooks do i add in? as the article is not very self explanatory. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 10, 2018 Share Posted July 10, 2018 1 hour ago, monsterit said: Ok, so if i did a standard php page that would work, but what hooks do i add in? you shouldn't necessarily need any hooks... if you don't need sidebars, specific variables etc, at the most basic, you can use the code in the thread below... <?php use WHMCS\ClientArea; define('CLIENTAREA', true); require __DIR__ . '/init.php'; $ca = new ClientArea(); $ca->setPageTitle('Current Promotions'); $ca->addToBreadCrumb('index.php', Lang::trans('globalsystemname')); $ca->addToBreadCrumb('kyle.php', 'Current Promotions'); $ca->initPage(); $ca->setTemplate('promotions'); $ca->output(); and then in the promotions.tpl template... {if $loggedin} here are a list of current promotions {else} you need to <a href="login.php">Login</a> to view this page. {/if} or if you want to redirect guests (non logged in users) to the login page... {if !$loggedin} <script type="text/javascript"> window.location.replace("login.php"); </script> {else} here are a list of current promotions {/if} another way, and probably the better method, would be to require login in the php file itself... <?php use WHMCS\ClientArea; define('CLIENTAREA', true); require __DIR__ . '/init.php'; $ca = new ClientArea(); $ca->setPageTitle('Current Promotions'); $ca->addToBreadCrumb('index.php', Lang::trans('globalsystemname')); $ca->addToBreadCrumb('kyle.php', 'Current Promotions'); $ca->requireLogin(); $ca->initPage(); $ca->setTemplate('promotions'); $ca->output(); and then the template no longer needs to check if the user is logged in (though it could for added security if you want to)... once upon a time... 1 hour ago, monsterit said: as the article is not very self explanatory. a lot of the documentation isn't fit for purpose... it doesn't include all the options available (and with encrypted software, how else are we supposed to know?), and some of the examples are vague/wrong/confusing for new users... 1 Quote Link to comment Share on other sites More sharing options...
monsterit Posted July 10, 2018 Author Share Posted July 10, 2018 Is there a way to add text etc there. I cant figure it out at the moment the code works and the page is showing. order.monster-it.co.uk/promotion.php But when i add code to make the body output its throwing a error 500. 0 Quote Link to comment Share on other sites More sharing options...
monsterit Posted July 10, 2018 Author Share Posted July 10, 2018 oh NM, figured it out thank you. Much appreciated. 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.