Zen Cart Logo
Forums / General Questions / Password protecting a category

Password protecting a category

Locked

Views: 2,598

Results 1 to 11 of 11
This thread is locked. New replies are disabled.
15 Feb 2008, 11:57 PM
#1
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Password protecting a category

I am referring to this search/thread:

http://www.zen-cart.com/forum/showthread.php?t=77302&highlight=password+protection

I also need to password protect one specific category in my cart.

I have copied Ajeh's code (posted 11th October 2007, 05:49 AM) from the thread as above and changed the category id to 36 (which is the one I want to protect). The category is called "Practitioner Only".

Then I tried to insert the code into various sections in the file

/includes/index_filters/default_filter.php

Every time I do this I am getting a parse error.

Could anyone please tell me where exactly (which line or lines) the code needs to be inserted in order to work properly.

Thank you all and happy zenning!

Frank

www.frnt.org/zencart/

16 Feb 2008, 6:08 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Password protecting a category

You might add to your post your details like the version of zencart you have etc.

What you have attempted

What template you are using
Modules you have installed

a link to your site

Any other pertinent info

16 Feb 2008, 6:43 AM
#3
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Password protecting a category

I am attempting to restrict access of users to one specific category. The user must be logged in or must register before they can access the category (ie. see images, descriptions and all..)

In my original post above I have referred to a similar problem by another zenner. Ajeh posted an answer to the other zenner's question but I don't know where exactly I need to insert the code provided by Ajeh - please click the link in my original post for more info.

My version is 1.3.7

I am using a custom template (incidentally is called 'custom' ).

Other modules installed are

SMS on order
Google analytics

A link to my site is also on my original post.

Thanks / Frank

PS will be offline until tomorrow morning Aussie time.

20 Feb 2008, 12:41 PM
#4
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Password protecting a category

I have been experimenting with a few ideas in the past week, mainly concentrating on the file .../includes/index_filters/default_filter.php

I feel that it is this file where I need to insert an "if" statement with these 2 conditions:

  1. customer clicks on category id = 36 (Practitioner Only)

and

  1. customer is not logged on

--> redirect customer to the login page.

If the customer is logged on they can view category id = 36 , no further questions asked.

Does anyone have an idea how this problem can be solved??

Any help is much appreciated.

Frank

frnt.org

2 Mar 2008, 11:08 AM
#5
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Password protecting a category

I have made some progress since my last post.

(BACKUP, BACKUP, BACKUP before you do any of this....)

  1. Redirecting a customer to the login page when they click on a specific manufacturer:

modify the file /includes/index_filters/default_filter.php as follows:

after the first

if (!isset($select_column_list)) $select_column_list = "";

insert this code

//if the customer calls for a specific manufacturer a n d the customer is not logged in
//then redirect them to the login page

if (!$_SESSION['customer_id'] && (isset($_GET['manufacturers_id']) && $_GET['manufacturers_id'] = '1' )) {
$_SESSION['navigation']->set_snapshot();
zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
}

this works perfectly.

If you want to use this code then just replace the '1' with the manufacturers id you want to block. Pre-condition: the products to block must have a manufacturer assigned to them.

  1. Redirecting a customer to the login page when they click on a specific category:

have tried anything and everything known to me in the file /includes/index_filters/default_filter.php with no avail.

then stumbled over the file /includes/functions/functions_categories.php

and inserted before

> return 'cPath=' . $cPath_new;

this code

if (!$_SESSION['customer_id'] && ($cPath_new = '36')) {
$_SESSION['navigation']->set_snapshot();
zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
}

Clicking on the category with id=36 (Practitioner Only) produces the desired result: the customer is redirected to the login page. Upon testing the other categories all work fine (without redirection) except for the categories "Gift Certificates" and "Supplements (all)" - clicking on these 2 cats ALSO produces a redirection. That's not what I want, these 2 cats are "Free For All" - no hiding or redirecting required.

What the :censored: am I doing wrong? :frusty:

To refresh your memories:

I am using v Zen Cart 1.3.7.1

the URL of my site is https://www.frnt.org/zencart/

Can anyone help please??

Once it's all done (with your kind help) I am planning to produce a mod and post it in the "Downloads" section for all to use at their pleasure (and risk).

Thanks heaps,

Frank

2 Mar 2008, 11:14 AM
#6
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Password protecting a category

frank18,

Thanks for sharing what you have discoverd for others that might also be seeking something along this line...

3 Mar 2008, 9:11 AM
#7
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Password protecting a category

thanks for your feedback, kobra

yes, there may be store owners who (for example) are selling adult orientated material and they need to keep minors away form this sort of stuff. It may be useful for them.

I am still puzzled why the code posted under number 2. (see above) is behaving as it does without any logical explanation.

Anyway, I never give up if there is a problem to solve. Old adage: if there is a problem then there is a solution.

I will keep plodding along ..... :yes:

Anyone has any ideas?

Cheers / Frank

https://www.frnt.org/zencart/


If you continue to do what you always did, then you will continue to be what you always were ....

3 Mar 2008, 11:21 AM
#8
misty avatar

misty

Inactive

Join Date:
Apr 2004
Location:
UK
Posts:
5,752
Plugin Contributions:
1

Re: Password protecting a category

Anyone has any ideas?
Wish I did frank18.. would also like solution..but not enough knowledge
on how to implement...hopefully zencart coder will provide solution.

3 Mar 2008, 5:43 PM
#9
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Password protecting a category

yes, there may be store owners who (for example) are selling adult orientated material and they need to keep minors away form this sort of stuff. It may be useful for them.
Frank,

While I have not completed my install and analysis of this - I have theorized a possible way to do this...

Using the multisite module(in the downloads section), one can have essentially 2+ sites using the same DB so what I am playing with(time permitting) is something along this line:

main_site.com = open frontend with only cats that can be openly viewed

other.main_site.com = closed frontend and could be passworded to only those that have been verified as ???? and contains all the cats in main plus additional cats only available here

This is not the original intention or why I am evaluating this but after a little play with it, it could do what you want

4 Mar 2008, 7:47 AM
#10
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Password protecting a category

hi Kobra,

didn't know about the multi site module. I have thought about this approach but shied away from it because of the extra work involved installing and testing the lot. But it may be an option. So, will get the module and do some experimenting (long weekend coming up so may get some time).

My gut feeling is that the solution (without 2 separate carts) is just around the corner. So, let's get our Sherlock Holmes hats on and keep digging.

Cheers / Frank

https://www.frnt.org/zencart/


"There is a principle which is a bar against all information, which is proof against all argument, and which cannot fail to keep man in everlasting ignorance. That principle is condemnation without investigation." (Herbert Spencer)

3 Aug 2008, 9:50 AM
#11
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Password protecting a category

It has been a while but I have taken up the idea again using Kobra's suggestion of the MultiSite module.

Posted a question on the dedicated MultiSite thread here

Cherrs / Frank

frNt.org