如何使我的Opencart成为仅可见的成员

时间:2015-05-23 12:42:39

标签: php opencart2.x

我已经安装了Opencart以使用在线目录。所以我必须让它只显示成员。我搜索了谷歌和stackoverflow。我找到了一些提示,但它们适用于1.5版本,并且不能通过我们的版本兼容。

我找到了两个扩展,它们也用于1.5版本。

我尝试了.htacces和.htpasswd对,但没有有用的解决方案。

我找到了这段代码。

但好像文件在版本2(我们的opencart版本)中不存在

// Check store ID against subdomain store id value
if($this->config->get('config_store_id') == 123) {

    // Check customer isn't logged in
    if(!$this->customer->isLogged()) {

        // Redirect if route isn't account/login
        if(empty($this->request->get['route']) ||     $this->request->get['route'] != 'account/login') {
            $this->redirect($this->url->link('account/login', '', 'SSL'));
        }
   }

}

因此;

如何将此代码应用于opencart 2和哪个文件。

任何帮助表示感谢。

1 个答案:

答案 0 :(得分:0)

以下是OC 2.0的代码。请在index()函数

中的catalog / controller / common / header.php上添加以下代码
 if (!$this->customer->isLogged()) {
       if (!isset($this->request->get['route']) || $this->request->get['route'] != 'account/login') {  

           $this->response->redirect($this->url->link('account/login', '', 'SSL'));
       }
    }

如果要同时启用注册和登录,请执行以下操作:

if (!$this->customer->isLogged()) {
       if (!isset($this->request->get['route']) || ($this->request->get['route'] != 'account/login' && $this->request->get['route'] != 'account/register')) {  

           $this->response->redirect($this->url->link('account/login', '', 'SSL'));
       }
    }