support

Hide content pages from users that aren't logged in

Started by picasso99, February 04, 2015, 05:18:49 PM

Previous topic - Next topic

picasso99

I asked this question in the General thread and was told it was a customization/code issue. If anyone can provide info on the file(s) that need tweaked and an idea on how to accomplish it, please help. I'm a software dev, so coding isn't a problem. However, I haven't had a chance to dig through the code to find a solution yet.

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.

llegrand

Have you looked into this extension -  Login to View Products?-  it seems as it might do what you want it to do.   For version 1.2  is says

Make your store private and require your customers to register or login to access your site or products.   This extension enables your storefront to require customer to register or login first before products, categories and brands can be seen.
http://marketplace.abantecart.com/marketing/login-to-view-products

picasso99

Thanks for the link. However, it looks too restrictive. There are things on the site that should be viewable without login. Products without pricing should be visible because retail customers should be able to see things they want their local dealer to order. That currently works as expected. I just need to be able to restrict visibility per content page, even if requires adding custom code when a new page is added.

picasso99

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) :

      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.

Forum Rules Code of conduct
AbanteCart.com 2010 -