Question

I used the solution of shadyyx like on this post

It works great.

But where in the code I should change something when I want to exclude the registration page? Otherwise customers cannot register because they get redirected to the login page...

class ControllerCommonLogin extends Controller {

public function index() {
    if($this->config->get('config_store_id') == 4) { // if desired store, continue checking

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

}

Thanks in advance..

Was it helpful?

Solution

Use this instead for the controller code

Class ControllerCommonLogin extends Controller {

    public function index() {
        if($this->config->get('config_store_id') == 1) { // if desired store, continue checking
            $skip = array(
                'account/login',
                'account/register',
            );

            $route = empty($this->request->get['route']) ? 'common/home' : $this->request->get['route'];

            if(!$this->customer->isLogged()) { // Check user isn't logged in
                if(!in_array($route, $skip)) { // Redirect if route isn't account/login
                    $this->redirect($this->url->link('account/login', '', 'SSL'));
                }
            }
        }
    }

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top