Opencart Force Login

前端 未结 4 2135
萌比男神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:57

    You need to add a condition like:

     if($this->config->get('config_store_id') == 1) { //Add your subdomain store id, if you want to limit the condition for a subdomain. 
    
          if( (!isset($this->request->get['route']) || $this->request->get['route'] != 'account/login' ) && (!$this->customer->isLogged()) ){
             $this->redirect($this->url->link('account/login', '', 'SSL'));
          }
     }
    

    $this->request->get['route'] - this will get you the current page path.

提交回复
热议问题