Post by newtread » Fri Jan 01, 2021 2:01 pm

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

Newbie

Posts

Joined
Mon Sep 30, 2013 12:02 am

Post by straightlight » Sat Jan 02, 2021 12:38 am

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.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by newtread » Sun Jan 03, 2021 4:43 am

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.

Newbie

Posts

Joined
Mon Sep 30, 2013 12:02 am
Who is online

Users browsing this forum: No registered users and 23 guests