Post by rishi » Sat Mar 24, 2012 7:52 pm

Hi,

I want to display products to the visitors after they sign in into the website.

I want to show the home page and all categories (drop down menu) to all visitors but when they click on any category i want to redirect them to login page if they are not logged in.

Which file needs to be modified to achive this?

Any suggestion is highly appreciated.

User avatar
New member

Posts

Joined
Mon May 17, 2010 5:34 am

Post by viviansank » Sat Mar 24, 2012 7:58 pm

i want too this module resources
;)

User avatar
New member

Posts

Joined
Wed Feb 22, 2012 9:49 pm

Post by rishi » Sun Mar 25, 2012 1:11 am

I have found one post in this issue.

http://forum.opencart.com/viewtopic.php ... ts#p232540

Using of Zen-Cart is suggested. I want to continue using OpenCart.

Any suggestion is highly appreciated.

User avatar
New member

Posts

Joined
Mon May 17, 2010 5:34 am

Post by rishi » Sun Mar 25, 2012 1:13 am

I have found another post in this issue but it is for old OpenCart.

http://forum.opencart.com/viewtopic.php ... 00#p207911


Any suggestion that works for latest OpenCart...?

User avatar
New member

Posts

Joined
Mon May 17, 2010 5:34 am

Post by rishi » Wed Mar 28, 2012 8:05 pm

Not solved till now.... any suggestion?

User avatar
New member

Posts

Joined
Mon May 17, 2010 5:34 am

Post by rishi » Sun Apr 15, 2012 1:09 am

:) :joker: :P :crazy: :drunk: :o 8) :-*

I solved this issue myself using following method. I'm posting it here so that someone with similar problem can get the help quickly.

Here is the detail about the code. The following code must be put after <head> code in header.tpl (front end template file) file.

What following code does?
1. First it obtains the current url name and assign it into the variable $pageURL using function curPageURL.
2. Secondly it compares with the url that are allowed to access with the $pageURL value.
3. If user try to open any page then the allowed one the code redirects to login page.

Code: Select all

<?php
function curPageURL() { 
 $pageURL = 'http'; 
  if (!empty($_SERVER['HTTPS'])) {if($_SERVER['HTTPS'] == 'on'){$pageURL .= "s";}} 
 $pageURL .= "://"; 
 if ($_SERVER["SERVER_PORT"] != "80") { 
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; 
 } else { 
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; 
 } 
 return $pageURL; 
}
?>

<?php
  $current_page_name = curPageURL();
      if ($current_page_name == 'http://www.mywebsitename.co.uk/index.php?route=account/forgotten') {
        $access_allow = "OK";
	} elseif ($current_page_name == 'http://www.mywebsitename.co.uk/test.php') {
        $access_allow = "OK"; 
	} elseif ($current_page_name == 'http://www.mywebsitename.co.uk/index.php') {
        $access_allow = "OK";
	} elseif ($current_page_name == 'http://www.mywebsitename.co.uk/index.php?route=account/register') {
        $access_allow = "OK"; 
	} elseif ($current_page_name == 'http://www.mywebsitename.co.uk/index.php?route=account/login') {
        $access_allow = "OK"; 
	} elseif ($current_page_name == 'http://www.mywebsitename.co.uk/index.php?route=common/home') {
        $access_allow = "OK"; 
	} else {
        $access_allow = "NOT";
        if (!$logged) { 
		header( 'Location: http://www.mywebsitename.co.uk/index.php?route=account/login' ) ;}
    }
?>

User avatar
New member

Posts

Joined
Mon May 17, 2010 5:34 am

Post by annelim » Fri May 04, 2012 2:38 pm

do you have any idea using this in multistore? i try it fail, only redirect to main page.

Active Member

Posts

Joined
Fri Oct 28, 2011 5:13 pm

Post by dickography » Mon Jan 30, 2017 9:09 am

annelim wrote:do you have any idea using this in multistore? i try it fail, only redirect to main page.
the below code works for multi-store
rishi wrote::) :joker: :P :crazy: :drunk: :o 8) :-*

I solved this issue myself using following method. I'm posting it here so that someone with similar problem can get the help quickly.

Here is the detail about the code. The following code must be put after <head> code in header.tpl (front end template file) file.

What following code does?
1. First it obtains the current url name and assign it into the variable $pageURL using function curPageURL.
2. Secondly it compares with the url that are allowed to access with the $pageURL value.
3. If user try to open any page then the allowed one the code redirects to login page.

Code: Select all

<?php
function curPageURL() { 
 $pageURL = 'http'; 
  if (!empty($_SERVER['HTTPS'])) {if($_SERVER['HTTPS'] == 'on'){$pageURL .= "s";}} 
 $pageURL .= "://"; 
 if ($_SERVER["SERVER_PORT"] != "80") { 
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; 
 } else { 
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; 
 } 
 return $pageURL; 
}
?>

<?php
  $current_page_name = curPageURL();
      if ($current_page_name == 'http://www.mywebsitename.co.uk/index.php?route=account/forgotten') {
        $access_allow = "OK";
	} elseif ($current_page_name == 'http://www.mywebsitename.co.uk/test.php') {
        $access_allow = "OK"; 
	} elseif ($current_page_name == 'http://www.mywebsitename.co.uk/index.php') {
        $access_allow = "OK";
	} elseif ($current_page_name == 'http://www.mywebsitename.co.uk/index.php?route=account/register') {
        $access_allow = "OK"; 
	} elseif ($current_page_name == 'http://www.mywebsitename.co.uk/index.php?route=account/login') {
        $access_allow = "OK"; 
	} elseif ($current_page_name == 'http://www.mywebsitename.co.uk/index.php?route=common/home') {
        $access_allow = "OK"; 
	} else {
        $access_allow = "NOT";
        if (!$logged) { 
		header( 'Location: http://www.mywebsitename.co.uk/index.php?route=account/login' ) ;}
    }
?>

Newbie

Posts

Joined
Sat Aug 13, 2016 9:27 am
Who is online

Users browsing this forum: No registered users and 41 guests