AbanteCart Community

eCommerce construction => General Discussion => Topic started by: picasso99 on February 02, 2015, 03:22:31 PM

Title: Content pages viewable by logged in users only
Post by: picasso99 on February 02, 2015, 03:22:31 PM
Is there a way to have content pages restricted to being viewed by logged in users only? I have a wholesale site that restricts viewing prices unless registered and authorized. I want to create a page with download links for a price list and literatures. However, I don't want non-registered users to have access to this page. I added a downloadable product, and it worked as expected, but it's cumbersome to go through the checkout process and then download the file(s). A simple page with links would be much better. I also have other pages that I would like to create for registered users only, such as delivery maps, how-to videos (how to sell our products, etc.), and other wholesale only information.
Title: Re: Content pages viewable by logged in users only
Post by: abantecart on February 04, 2015, 10:51:14 AM
Unfortunately, content pages do not have extensive CMS features. There is no way to restrict content.

code modification is required for what you are looking to do.

Title: Re: Content pages viewable by logged in users only
Post by: picasso99 on February 04, 2015, 12:45:33 PM
I have no problems with code modifications, but unsure where to start.
Title: Re: Content pages viewable by logged in users only
Post by: picasso99 on February 06, 2015, 09:56:38 AM
Figured it out. I did the following:

Added a content page with the authorized info. Content_id = 8.
Added a content page with the notice "Authorized users only." Content_id = 9
Modified "/storefront/controller/pages/content/content.php" as below (changes in red) :
Code: [Select]
      if (isset($this->request->get['content_id'])) {                     
          /* customer is logged in OR content_id != 8 (authorized content) */
         if ($this->customer->isLogged()
         or $this->request->get['content_id'] != 8 ) {
            $content_id = $this->request->get['content_id'];
         else
         {
             /* show "Authorization Required" content page */
            $content_id = 9;
         }
      } else {
         $content_id = 0;
      }

Add all authorized content pages to the second IF statement.