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.
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.
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.
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...?
http://forum.opencart.com/viewtopic.php ... 00#p207911
Any suggestion that works for latest OpenCart...?
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' ) ;}
}
?>
the below code works for multi-storeannelim wrote:do you have any idea using this in multistore? i try it fail, only redirect to main page.
rishi wrote:
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' ) ;} } ?>
Who is online
Users browsing this forum: Bing [Bot] and 307 guests