Forums / General Questions / How to allow a guest to access only certain products

How to allow a guest to access only certain products

Started by jodean on 30 Aug 2015, 10:09 PM · Views: 643

Results 1 to 3 of 3
30 Aug 2015, 10:09 PM
#1
jodean avatar

jodean

Totally Zenned

Join Date:
May 2011
Location:
Tennessee
Posts:
511
Plugin Contributions:
0

How to allow a guest to access only certain products

My website is a membership store. We require a new user to be confirmed as a member before giving them access to the product pages. However we would like to allow a guest access to the join membership product page only.

Does anyone have an idea how I could accomplish this?

30 Aug 2015, 11:52 PM
#2
balihr avatar

balihr

Totally Zenned

Join Date:
Oct 2008
Location:
Croatia
Posts:
1,811
Plugin Contributions:
22

Re: How to allow a guest to access only certain products

If it's just the product pages, you could use something like:

if(!$_SESSION['customer_id'] && $_GET['products_id'] != 'MEMBERSHIP_PRODUCT_ID') {
    zen_redirect......
}

and redirect to the membership page.

if($_SESSION['customers_authorization'] > 0) {
    zen_redirect......
}

and redirect to any page that explains they are still not authorized.

I'd put it in includes/modules/pages/product_info/header_php.php (although it would be wiser to do it using an observer, I know I know...).

My site - Pro ZC Help
My portfolio | My plugins

31 Aug 2015, 4:00 AM
#3
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: How to allow a guest to access only certain products

balihr:

(although it would be wiser to do it using an observer, I know I know...).

Hahaha... :) points for acknowledging the wiser option.. :) similar code for both "styles", at least the "action" part.

Sorry chimed in cuz of the above. :) could reference the last time an observer was created to sort out a similar issue at least that way an example of an observer would be present and the above code could be used "further". :)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...