Jump to content
BlackXS

Restrict all page except Cart and product

Recommended Posts

Hi guys,

I have difficulties to achieve one thing I saw on another site that also has WHMCS.

My clients can not register theirself at WHMCS without ordering, so when they make an order, they will create a WHMCS account (for this there is options in WHMCS Config so i got this).
Now I want to hide all the pages at WHMCS except for the ordering, the cart and of course products. So, first time when visitor go to mydomain.com/whmcs it says "Restricted Pages" but when he goes
to product page, I want that he/she can see that page.

Only hook I find on this site is forceeveryonetologin.php but unfortunately, this is not good, because in this case, the user(first time visitor) can not see all the pages including the product, cart because they have not been registered before.

I hope that you understand me :)

Share this post


Link to post
Share on other sites
19 hours ago, BlackXS said:

Only hook I find on this site is forceeveryonetologin.php but unfortunately, this is not good, because in this case, the user(first time visitor) can not see all the pages including the product, cart because they have not been registered before.

do you mean sentq hook from the thread below...

if so, all you need to do is to expand the code to include additional pages that you want the customer to be able to see...

<?php
if (!defined("WHMCS"))
   die("This file cannot be accessed directly");

function hook_ForceEveryoneToLogin($vars) {

	$client = Menu::context('client');
	$validpages = array("login","dologin","clientarea","pwreset","cart","contact","index");
	if (!$client && !in_array($vars['filename'],$validpages)) {
		header("Location: login.php");
		exit;
	}
}
add_hook("ClientAreaPage", 1, "hook_ForceEveryoneToLogin");

index will show the homepage, and might be required too if you are offering MarketConnect products...

Share this post


Link to post
Share on other sites

Hi @brian!

That it's that hook from that topic I used.

That's exactly what I needed, thank you very much, now it's just as I wanted to achieve.

 

Kind regards!

Share this post


Link to post
Share on other sites

I tried this code that works thanks! only one problem I use a theme which calls the pwreset page in this way: password-reset-change-prompt.tpl | password-reset-container.tpl etc. I can't seem to include it's page in the code so that it doesn't get locked. would there be a tip for this page

Share this post


Link to post
Share on other sites
On 13/09/2020 at 02:54, drenixweb said:

only one problem I use a theme which calls the pwreset page in this way: password-reset-change-prompt.tpl | password-reset-container.tpl etc. I can't seem to include it's page in the code so that it doesn't get locked. would there be a tip for this page

what you may need to do is a double check - e.g check for filenames (as currently written) and check for specific templates (e.g an array of your password templates) and then adjust the if statement to check both before redirecting.

Share this post


Link to post
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