Post by plutonium78 » Sat Sep 02, 2023 7:00 am

I am using Opencart 3.0.8

I would like only registered users to read our blog and certain information pages. How do I make this happen?

Standard blog or Information pages have no permission settings. There is also no permission settings in Customer groups or Settings.

Please advise.
Last edited by plutonium78 on Mon Sep 18, 2023 6:08 am, edited 1 time in total.

Newbie

Posts

Joined
Thu Jun 01, 2023 10:27 pm

Post by Johnathan » Sat Sep 02, 2023 9:16 pm

You can't restrict pages by customer group in a default OpenCart installation, so you'd need an extension. I have on called Block Products and Pages that lets you do that. You can limit pages based on URL and a variety of other rules, including customer group.

Feel free to take a look at the screenshots and demo site, and if you're interested let me know at www.getclearthinking.com/contact if you have any questions.

Image
Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by SohBH » Sat Sep 02, 2023 11:35 pm

Code: Select all

if ($this->customer->isLogged()) {
    // User is logged in, show the content
} else {
    $this->response->redirect($this->url->link('account/login', '', true));
}

If you are interested in discussing your web development needs with me, please feel free to contact me at
soh.bheng@gmail.com


User avatar
Active Member

Posts

Joined
Mon Nov 02, 2020 12:01 am
Location - Malaysia

Post by plutonium78 » Sun Sep 03, 2023 3:24 am

SohBH wrote:
Sat Sep 02, 2023 11:35 pm

Code: Select all

if ($this->customer->isLogged()) {
    // User is logged in, show the content
} else {
    $this->response->redirect($this->url->link('account/login', '', true));
}
Bro, if you insert your code into template/blog/blog.twig - it just producers ERROR 500

Newbie

Posts

Joined
Thu Jun 01, 2023 10:27 pm

Post by SohBH » Sun Sep 03, 2023 1:02 pm

Why would you insert PHP code into a Twig file? There is php file in controller.

If you are interested in discussing your web development needs with me, please feel free to contact me at
soh.bheng@gmail.com


User avatar
Active Member

Posts

Joined
Mon Nov 02, 2020 12:01 am
Location - Malaysia

Post by plutonium78 » Mon Sep 18, 2023 6:02 am

Thanks, bro! Your code worked in php file.
Just need to add it after a line: public function index() {

Newbie

Posts

Joined
Thu Jun 01, 2023 10:27 pm
Who is online

Users browsing this forum: No registered users and 2 guests