Forums / All Other Contributions/Addons / Show products_url only when loged in

Show products_url only when loged in

Locked

Views: 2,170

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
15 May 2006, 9:52 AM
#1
teva avatar

teva

Zen Follower

Join Date:
Sep 2004
Posts:
101
Plugin Contributions:
0

Show products_url only when loged in

I want to hide url link from not registered customers, is this possible?
So $products_url is only shown where user is loged in.

Thank you

15 May 2006, 10:32 AM
#2
teva avatar

teva

Zen Follower

Join Date:
Sep 2004
Posts:
101
Plugin Contributions:
0

Re: Show products_url only when loged in

I'm not a php programer, so i could be way off.

Looking at index.php in language dir, i notice that greeting is formated in that way.

So i tried the same thing for URL, but it does not work.

if (STORE_STATUS == '0') {
  define('TEXT_MORE_INFORMATION', 'Url is not shown');
} else {
  define('TEXT_MORE_INFORMATION', 'Url is showing');
}

Later on, i found that something is also defined in functions_customers.php and that is really complicated for me. Any idea how to proced?

Tnx

15 May 2006, 10:38 AM
#3
kobra avatar

kobra

Black Belt

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

Re: Show products_url only when loged in

In your admin go to:

Configuration > Customer Details > Customer Approval Status - Authorization Pending > and set to "1"

Zen-Venom Get Bitten

15 May 2006, 10:52 AM
#4
teva avatar

teva

Zen Follower

Join Date:
Sep 2004
Posts:
101
Plugin Contributions:
0

Re: Show products_url only when loged in

Tnx kobra, but wouldn't this also hide all other info about product?
I only want URL link to hide from not registered users. I'm linking this url to PDF document, that has some info, only registered customers cas see.
I'm using showcase only

Well, i looked into function_customers.php and added this

 // Hide url
   function show_url() {
      if ($_SESSION['customer_first_name'] && $_SESSION['customer_id']) {
      $url_string = sprintf(TEXT_MORE_INFORMATION, zen_output_string_protected($_SESSION['customer_first_name']), zen_href_link(FILENAME_PRODUCTS_NEW));
    } else {
      $url_string = sprintf(TEXT_MORE_INFORMATION_URL, zen_href_link(FILENAME_LOGIN, '', 'SSL'), zen_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'));
    }

    return $url_string;
  }

In tpl_products_info_display.php i replaced

<?php // echo sprintf(TEXT_MORE_INFORMATION, $products_url); ?>

with

<?php echo show_url(); ?>

in languages products_info.php i added

define('TEXT_MORE_INFORMATION_URL', 'You have to be loged in to see this');
below
define('TEXT_MORE_INFORMATION', 'Please click <a href="%s" target="_blank">here, for PDF</a>.');

This works fine, but the problem now is, that %s is not showing url to PDF, but username of loged customer.

I'm aware that this must be very funy for someone who is experienced in php, but i'm graphic designer and programing is really not my thing.

Anyway if someone can check this and give me a little help, i would be wery grateful.

tnx

15 May 2006, 11:17 AM
#5
kobra avatar

kobra

Black Belt

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

Re: Show products_url only when loged in

I want to hide url link from not registered customers, is this possible?
So $products_url is only shown where user is loged in.
Sorry, I read this as the URL to the product pages...& not to a PDF.

I am also not a php coder by any definition.

Maybe by keeping this at the top, one of the php Zenners will chime in.

Zen-Venom Get Bitten

20 May 2006, 1:25 AM
#6
teva avatar

teva

Zen Follower

Join Date:
Sep 2004
Posts:
101
Plugin Contributions:
0

Re: Show products_url only when loged in

Hey!

Sorry for bumping this, but does anybody have any idea how to solve my problem?

Tnx

20 May 2006, 8:57 AM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Show products_url only when loged in

Try this:```php
// Hide url
function show_url($products_url='') {
if ($_SESSION['customer_id'] && $products_url !='') {
$url_string = sprintf(TEXT_MORE_INFORMATION, $products_url);
} else {
$url_string = sprintf(TEXT_MORE_INFORMATION_URL, zen_href_link(FILENAME_LOGIN, '', 'SSL'), zen_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'));
}
return $url_string;
}

In tpl_products_info_display.php replace```php
<?php // echo sprintf(TEXT_MORE_INFORMATION, $products_url); ?>

with```php

<?php echo show_url($products_url); ?>

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

20 May 2006, 9:34 PM
#8
teva avatar

teva

Zen Follower

Join Date:
Sep 2004
Posts:
101
Plugin Contributions:
0

Re: Show products_url only when loged in

Yes! Thank you Sensei, this works great.