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