Opencart Force Login

前端 未结 4 2133
萌比男神i
萌比男神i 2020-12-12 01:28

I would like to redirect a customer to the login page if they are not logged in from any page on the site. I am trying to limit access to a subdomain to a specific customer

4条回答
  •  执笔经年
    2020-12-12 01:44

    Assuming you want to check the store is the subdomain one as well, you should use code something like this

    // 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'));
            }
        }
    }
    

提交回复
热议问题