Zen Cart Logo
Forums / Managing Customers and Orders / Hide Items from non-registered users

Hide Items from non-registered users

Locked

Views: 3,449

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
15 Jan 2007, 7:33 AM
#1
kgmmusic avatar

kgmmusic

New Zenner

Join Date:
Nov 2005
Posts:
76
Plugin Contributions:
0

Hide Items from non-registered users

I am building a site and the client would like to hide certain items from users who are not logged in.

EXAMPLE: Ask A Question (MOD) installed
DISPLAY: Only for logged in users (otherwise hidden)

I noticed that there is a switch in Admin/Email to "allow guest to tell a friend" and assume that this would work the same way but I'm not sure what code to add where.

There are other items that may need this restriction so I'm wondering if there is a "standard" piece of HTML/PHP code I can insert into the template files to to check to see if the user is logged then display the content, if not logged in then hide the content?

TEST LINK: http://70.85.24.162/index.php?main_page=product_info&cPath=1_2&products_id=1

THANK YOU ALL!!!

15 Jan 2007, 12:05 PM
#3
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,694
Plugin Contributions:
56

Re: Hide Items from non-registered users

Remember too that certain abilities to hide things are already built in to Zen Cart; try out Admin->Configuration->Customer Details->Customer Shop Status - View Shop and Prices to see some of the possible variants.

To address your example specifically, AAQ is probably not something you want to only allow customers to do - you'll have more conversions if guests can ask about your products without having to create an account. TAF is (optionally) login restricted to keep spammers from exploiting your site.

Good luck,
Scott

16 Jan 2007, 7:51 AM
#4
kgmmusic avatar

kgmmusic

New Zenner

Join Date:
Nov 2005
Posts:
76
Plugin Contributions:
0

Re: Hide Items from non-registered users

misty:

http://www.zen-cart.com/forum/showthread.php?t=27529&highlight=members
Above previous forum post may help

Thanks misty for pointing me in the right direction. I added bunyip's code (see below) and with a few modifications I was able to hide certain content from non-users. THANKS AGAIN!!!

<-----START CODE--->
if ($_SESSION['customer_id']) {
// display this link for logged in user
echo '<a href="http://www.yoursite.com">Link</a>';
} else {
//display something else for user not logged in
echo 'you'd see a cool link here if you were logged in';
}
<-----END CODE--->

16 Jan 2007, 7:54 AM
#5
misty avatar

misty

Inactive

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

Re: Hide Items from non-registered users

Thanks misty for pointing me in the right direction.
No problem, glad to hear you achieved required result
:smile:

26 Jan 2007, 1:03 AM
#6
mirmir37 avatar

mirmir37

New Zenner

Join Date:
Dec 2006
Posts:
7
Plugin Contributions:
0

Re: Hide Items from non-registered users

I kind of want to do the same thing as kgmmusic (i.e. hide info from guests), except the only information I want to hide is the price. And I only want to hide the prices of certain products from browsers, but allow them to see the prices of other products. Is there a way to do this?

26 Jan 2007, 9:38 AM
#7
redxiii avatar

redxiii

New Zenner

Join Date:
Jun 2006
Posts:
58
Plugin Contributions:
0

Re: Hide Items from non-registered users

only for certain products, which are controlled by their ID(or group like manufacturer), sounds to me that ZC requires that reference, be it a new database table, a read file like defines, or another field in products table(db) like hide_price_from_guest(boolean).

it's after that when you start placing a code like...

if (($_SESSION['customer_id']) && (zen_get_hide_value((int)$_GET['products_id'])) {

note: the zen_get_hide_value is only a sample custom function.

26 Jan 2007, 12:23 PM
#8
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,694
Plugin Contributions:
56

Re: Hide Items from non-registered users

FYI: it's not a good practice to preface custom function names with "zen_." Imagine how unhappy you'd be if in the next release the core team creates a function with the same name! Just use regular names instead.

Scott

28 Jan 2007, 4:16 AM
#9
mirmir37 avatar

mirmir37

New Zenner

Join Date:
Dec 2006
Posts:
7
Plugin Contributions:
0

Re: Hide Items from non-registered users

redxiii:

only for certain products, which are controlled by their ID(or group like manufacturer), sounds to me that ZC requires that reference, be it a new database table, a read file like defines, or another field in products table(db) like hide_price_from_guest(boolean).

it's after that when you start placing a code like...

if (($_SESSION['customer_id']) && (zen_get_hide_value((int)$_GET['products_id'])) {

note: the zen_get_hide_value is only a sample custom function.

Thanks for the hint, but not being well versed in PHP, I don't know how exactly to apply this. Could you give me a general step by step on how to implement it? (i know that each database/store is going to be different, but maybe you know generally how I can do this)