Page 1 of 1

Restrict access to specific information pages based on customer group with SSL enabled.

Posted: Fri Jan 01, 2021 2:01 pm
by newtread
In Opencart version 1.5.4.1 I used the following code to restrict access to information page 7 if the customer is in group 1. It works fine with SSL disabled but will not work with SSL enabled. What can I do to get it working with SSL?

To restrict access to certain information pages you can check for requested information_id and current user group, then output custom content:

in catalog/controller/information/information.php find line 62:

$this->response->setOutput($this->render());
} else {
......

Add before:

$id = $this->customer->getCustomerGroupId();
if ($id == 1 && $information_id == 7){
$this->data['heading_title'] = 'Not allowed.';
$this->data['description'] = 'You are not allowed to view this page';
}

Re: Restrict access to specific information pages based on customer group with SSL enabled.

Posted: Sat Jan 02, 2021 12:38 am
by straightlight
While a simple event could do it on more recent OC versions, rather than playing with core files, I would suggest to use the $this->response->addHeader with 404 as a response page rather than hardcoding an error page without using the header. The catalog/controller/product/product.php file would be one of the examples on how to achieve this specifically.

Re: Restrict access to specific information pages based on customer group with SSL enabled.

Posted: Sun Jan 03, 2021 4:43 am
by newtread
I have 2 customer groups. Group one can not see pricing. I need to create an information page that only group 2 can view since it will contain a link to a pdf catalog that contains pricing.