Jump to content

Restrict all page except Cart and product


BlackXS

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 :)

Link to comment
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...

Link to comment
Share on other sites

  • 1 year later...

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

Link to comment
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.

Link to comment
Share on other sites

  • 3 years later...

This hook works well,  but for my use case I need something else.

Essentially I want to show the products and cart but no other page other wise. The reason is that I have my own custom frontend (not built using whmcs templates) and I want to redirect the user to that custom page if that customer isn't logged in except in the case they want to see the products and subsequently the cart. Adding "index" in the valid pages also allows the user to see the login page of whmcs which I do not want. The user should only see my custom page which has the login, signup, e.t.c functionality already implemented.

Can someone help with updating the above hook. 

Thanks in advance

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