Try this, in catalog\controller\common\header.php
after public function index() {
add:
// Where all visitors can access
$allowed_routes = array(
'product/category',
'common/home',
'account/register',
'account/login',
'account/logout',
'account/forgotten',
);
// Who can access
$allowed_customer_group_id = array(
1,
2,
3
);
$current_customer_group_id = $this->config->get('config_customer_group_id');
if($this->request->get['route']){
$current_page = $this->request->get['route'];
} else {
$current_page = 'common/home';
}
// notification
$data['notice'] = '';
if(!in_array($current_customer_group_id, $allowed_customer_group_id) || !$this->customer->isLogged()){
if(!in_array($current_page, $allowed_routes)){
// not allowed
// do something, redirect to login page
if($this->customer->isLogged()){
$this->response->redirect($this->url->link('common/home', '', true));
} else {
$this->response->redirect($this->url->link('account/login', '', true));
// or $this->response->redirect($this->url->link('account/register', '', true));
}
} else {
$data['notice'] = 'Some notification message here!';
}
}
and somewhere in catalog\view\theme\default\template\common\header.twig
add:
{% if notice %}
<p class="alert alert-info">{{ notice }}</p>
{% endif %}
Finally you may need to clear caches (twig cache, ocmod cache, vqmod cache etc ...)