Forums / Templates, Stylesheets, Page Layout / Link only show when logged in

Link only show when logged in

Locked

Views: 1,867

Results 1 to 12 of 12
This thread is locked. New replies are disabled.
22 Jan 2010, 2:35 PM
#1
twdhosting avatar

twdhosting

Zen Follower

Join Date:
Mar 2005
Posts:
119
Plugin Contributions:
0

Link only show when logged in

I've changed the code of /modules/sideboxes/information.php so that the link to "Page 4" only shows when a customer is logged in

if ($_SESSION['customer_id']) {
$information[] = '<a href="' . zen_href_link(FILENAME_PAGE_4) . '">' . BOX_INFORMATION_PAGE_4 . '</a>';
}

But I have just realised that this bypasses the customer authorisation process, I want the link to only show when an authorised customer is logged in? At the moment the link shows as soon as a customer registers (not approved)

Any suggestions please?

Thanks

22 Jan 2010, 4:54 PM
#2
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Link only show when logged in

I don't know how to write it but you need to add a supplementary condition to

if (($_SESSION['customer_id']) and customer status = approved){
$information[] = '<a href="' . zen_href_link(FILENAME_PAGE_4) . '">' . BOX_INFORMATION_PAGE_4 . '</a>';
}

20 years a Zencart User

25 Jan 2010, 1:02 PM
#3
twdhosting avatar

twdhosting

Zen Follower

Join Date:
Mar 2005
Posts:
119
Plugin Contributions:
0

Re: Link only show when logged in

Thanks for that - I tried it but it doesn't work... It screws up the page loading so I think the coding is wrong?

Anyone else know how to do this?

Thanks

Tony

25 Jan 2010, 1:23 PM
#4
twdhosting avatar

twdhosting

Zen Follower

Join Date:
Mar 2005
Posts:
119
Plugin Contributions:
0

Re: Link only show when logged in

I've also tried the following:

if ($_SESSION['customer_id'] and CUSTOMERS_APPROVAL =='1') {
$information[] = '<a href="' . zen_href_link(FILENAME_PAGE_4) . '">' . BOX_INFORMATION_PAGE_4 . '</a>';
}

but that didn't work...?

25 Jan 2010, 3:08 PM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Link only show when logged in

I believe the problem is due to what you are testing for ...

You want logged in customers who are "authorized" to be able to see page 4 ...

You are currently testing for logged in customer with $_SESSION['customer_id'] ... but then you are testing also with the "setting" for the Authorization with CUSTOMERS_APPROVAL rather than the current customers authorization status ...

Also, an approved customer has the customers_authorization field set to 0 in the customers table, not 1 ...

Try using:

if ($_SESSION['customer_id'] > 0 && $_SESSION['customers_authorization']  == 0) {

Now, this will check the current customer to make sure that:
1 the customer is logged in

2 the customer is approved

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

25 Jan 2010, 3:31 PM
#6
twdhosting avatar

twdhosting

Zen Follower

Join Date:
Mar 2005
Posts:
119
Plugin Contributions:
0

Re: Link only show when logged in

That worked great - thanks Ajeh! :)

25 Jan 2010, 4:09 PM
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Link only show when logged in

You are most welcome ... thanks for thie update that this was able to work for you on customers having to be logged in and authorized before being allowed to see specific links ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

9 Aug 2010, 12:11 AM
#8
dimsumgurl avatar

dimsumgurl

Zen Follower

Join Date:
Dec 2009
Location:
Canada
Posts:
160
Plugin Contributions:
0

Re: Link only show when logged in

This thread seems simliar to what I am trying to get...

I want my header links to be visible only when they are logged in and authorized.

I am not a coding wiz so I would not know what files I would need to mod or how.

Could someone point me in a direct on how to achieve this?

It would be a mighty big help!!

THANK you in advance! :)

9 Aug 2010, 1:30 AM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Link only show when logged in

You would need to manage your links with something like:

if ($_SESSION['customer_id'] > 0 && $_SESSION['customers_authorization']  == 0) {
  // show links here customer is logged in and authorized
} else {
  // do not show links or show something else
}

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

9 Aug 2010, 1:45 AM
#10
dimsumgurl avatar

dimsumgurl

Zen Follower

Join Date:
Dec 2009
Location:
Canada
Posts:
160
Plugin Contributions:
0

Re: Link only show when logged in

hey Ajeh. Thanks for your reply and tip. Would that be modified in the tpl_main_page.php or init_customer_auth.php?

9 Aug 2010, 2:48 AM
#11
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Link only show when logged in

You would be using the IF condition for your links that you want to control based on the condition ...

Most likely, this would be in one of your tpl_ template files in your templates and override directories ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

16 Aug 2010, 12:12 AM
#12
dimsumgurl avatar

dimsumgurl

Zen Follower

Join Date:
Dec 2009
Location:
Canada
Posts:
160
Plugin Contributions:
0

Re: Link only show when logged in

I've located the tpl_ezpages_bar_header.php and am trying to implement a simliar code of

"<?php if ($_SESSION['customer_id'] > 0 && $_SESSION['customers_authorization'] == 0) {"

how can that apply to something like navEZPagesTop?