Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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!';
- }
- }
- {% if notice %}
- <p class="alert alert-info">{{ notice }}</p>
- {% endif %}
Add Comment
Please, Sign In to add comment