OSCOMMERCE SUPPORT CALL 702-453-3332

 

Help - Search - Members - Calendar
Full Version: Need help in script
osCommerce Community Support Forums > osCommerce Online Merchant v2.x > General Support
fxtrader777
Hello all

How can I add script which allows only registered users to view products, and guests should only see headlines


thanks
sutikah1
QUOTE (fxtrader777 @ Jan 6 2008, 08:15 AM) *
Hello all

How can I add script which allows only registered users to view products, and guests should only see headlines
thanks


Try searching the CONTRIBUTIONS section.
FWR Media
This may give you some ideas for index.php (You would have to do similar for products_info.php)

This is untested so if you play about with this ensure you have backed up any files you change.


Find ...

CODE
<?php
  if ($category_depth == 'nested') {

Change to ...

CODE
<?php
$show_products = ( (tep_session_is_registered('customer_id')) ? true : false );
if ($show_products) {
  if ($category_depth == 'nested') {



Find ...

CODE
<?php
  }
?>
<!-- body_text_eof //-->


Change to ...


CODE
<?php
  }
  } elseif ($show_products == false) {
    //echo $show_headlines;  // Whatever your variable is for showing headlines
    // show_headlines();
    // Or whatever you use to show headlines :)
  }
?>
<!-- body_text_eof //-->


Hope that helps
fxtrader777
Thank you babygurgles


I modified index.php but do not understand how to modify product_info.php I could not find that scripts in product_info.php


Also when I uploaded index.php the body dissapeared, newsdesk and products box dissapeared and where I logged in they appeared again. This is what I needed but can I do more accurately, meaning when guest is on home page it should see newsdesk and new products box but when he clicks some specific news the site must give him a notice that he cannot review until he is registered.


I am not good at php and hope you understand what I need (if you know there is something in contributions please direct me to appropriate link)

thank you very much
FWR Media
QUOTE (fxtrader777 @ Jan 6 2008, 09:40 AM) *
Also when I uploaded index.php the body dissapeared, newsdesk and products box dissapeared and where I logged in they appeared again.


That is because you have set no headlines to show. In my example the methods to show the headlines are comented (//) out

i.e.

CODE
    //echo $show_headlines;  // Whatever your variable is for showing headlines
    // show_headlines();
    // Or whatever you use to show headlines :)



If you change that bit to ..

CODE
   $headlines = 'The user is not logged in so I am now showing headlines<br />';
    echo $show_headlines;


You will see that a guest sees the above text.
fxtrader777
I did it but no notice appears sad.gif


I need unregistered users to see home page as it is for registered users, but when guests click on some specific news or product there must be a notice

please register!

thank you

Also what about pdocut_info.php

I could not modify it
FWR Media
QUOTE (fxtrader777 @ Jan 6 2008, 10:09 AM) *
I did it but no notice appears sad.gif
I need unregistered users to see home page as it is for registered users, but when guests click on some specific news or product there must be a notice

please register!

thank you



Ooops my bad
CODE
$headlines = 'The user is not logged in so I am now showing headlines<br />';
    echo $show_headlines;


Should be ..

CODE
        $show_headlines = 'The user is not logged in so I am now showing headlines<br />';
        echo $show_headlines;
fxtrader777
Thank you it really worked out,

And what about product_info.php you have advised to modify it too

What should I do for this file

thanks
FWR Media
Firstly another little change to show the "please register"

CODE
        $show_headlines = echo '
        Please <a href = "' . tep_href_link(FILENAME_LOGIN) . '">register or log in</a> to view our products<p />
        The user is not logged in so I am now showing headlines<br />';
        echo $show_headlines;


Regarding the product_info.php, you'll have to have a go yourself or I'll have a quick bash when I come back later.
fxtrader777
QUOTE (Babygurgles @ Jan 6 2008, 11:21 AM) *
Firstly another little change to show the "please register"

CODE
        $show_headlines = echo '
        Please <a href = "' . tep_href_link(FILENAME_LOGIN) . '">register or log in</a> to view our products<p />
        The user is not logged in so I am now showing headlines<br />';
        echo $show_headlines;


Regarding the product_info.php, you'll have to have a go yourself or I'll have a quick bash when I come back later.



thank you very much it worked, I placed <img> tag which is centered and asks guest to submit registration

and what about product_info.php

I think newsdesk_info.php must be modified no?

and one question if you do not mind

Can I make like that, when guest goes to homepage everything appears like it is for registered user, but when guest tries to click on product there is notice "Please register"

this script what you gave me really helped me to keep unregistered users from viewing my products, but a little more correction will be good if I can let unregistered users see product names but not content.

thank you very much, I will be back in 1-2 hours

you are very helpful person on this forum

thanks
fxtrader777
Kind user please be back sad.gif
FWR Media
you could try the following ...

In /includes/application_top.php

find ...

CODE
$navigation->add_current_page();


Add below it ..

CODE
// FWRMedia mod to redirect to login when cPath is present and user not logged in
$logged_in = ( (tep_session_is_registered('customer_id')) ? true : false );
( ($logged_in == false && isset($_GET['cPath'])) ? tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')) : false );
// End FWRMedia mod


Try that.
fxtrader777
QUOTE (Babygurgles @ Jan 6 2008, 04:57 PM) *
you could try the following ...

In /includes/application_top.php

find ...

CODE
$navigation->add_current_page();


Add below it ..

CODE
// FWRMedia mod to redirect to login when cPath is present and user not logged in
$logged_in = ( (tep_session_is_registered('customer_id')) ? true : false );
( ($logged_in == false && isset($_GET['cPath'])) ? tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')) : false );
// End FWRMedia mod


Try that.


Hello kind user

It really worked out for categories, when I click link in categories there is what I need (login box appears)

but it did not work for home page, I mean when guest enters the site there is headline (what we made yesterday),

I removed the script of headline from index.php and the guests see products on first page but when it clicks on it nothing happens he can view as registered users

we need to make so that when guest enters the site he must see as it is, but when he attempts to click on some specific product then there should be login box asking to log in or register (it really worked out for categories box)

thanks

see attached image to be clarified

fxtrader777
uppp uppp ...................
fxtrader777
kind user

please be back sad.gif
just one problem, I cannot sell anyting withought fixing this problem sad.gif
FWR Media
QUOTE (fxtrader777 @ Jan 7 2008, 01:30 PM) *
kind user

please be back sad.gif
just one problem, I cannot sell anyting withought fixing this problem sad.gif



I have helped where I can but I'm not going to do it all for you. I'm currently working for paying clients.

Good luck
sutikah1
QUOTE (fxtrader777 @ Jan 7 2008, 06:29 AM) *
Hello kind user

It really worked out for categories, when I click link in categories there is what I need (login box appears)

but it did not work for home page, I mean when guest enters the site there is headline (what we made yesterday),

I removed the script of headline from index.php and the guests see products on first page but when it clicks on it nothing happens he can view as registered users

we need to make so that when guest enters the site he must see as it is, but when he attempts to click on some specific product then there should be login box asking to log in or register (it really worked out for categories box)

thanks


If it really worked for categories, DUPLICATE your actions for everything you want the unregistered user blocked from.
Coopco
QUOTE (Babygurgles @ Jan 8 2008, 01:03 AM) *
I have helped where I can but I'm not going to do it all for you. I'm currently working for paying clients.

Good luck

That is the problem, they demand everything to be gratis instead of trying things out for themselves.
sutikah1
QUOTE (Coopco @ Jan 7 2008, 03:07 PM) *
That is the problem, they demand everything to be gratis instead of trying things out for themselves.


Aint that the truth, Leslie! rolleyes.gif
Coopco
QUOTE (sutikah1 @ Jan 8 2008, 02:10 AM) *
Aint that the truth, Leslie! rolleyes.gif

To the point whare they steal from your site.
fxtrader777
Someone give me a hint?

what file to edit like I did for application_top.php?

thanks

I tried to paste that script in newsdesk.php, but I got error biggrin.gif
fxtrader777
up
FWR Media
This should do it fxtrader777

In /includes/application_top.php

find ...


CODE
$navigation->add_current_page();



Add below it ..


CODE
// FWRMedia mod to redirect to login when $_GET['cPath'] or $_GET['newsdesk_id'] is present and user not logged in
$logged_in = ( (tep_session_is_registered('customer_id')) ? true : false );
$redirect = ( (isset($_GET['cPath']) || isset($_GET['newsdesk_id'])) ? true : false );
( ($logged_in == false && $redirect == true) ? tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')) : false );
// End FWRMedia mod
fxtrader777
QUOTE (Babygurgles @ Jan 9 2008, 09:08 AM) *
This should do it fxtrader777

In /includes/application_top.php

find ...
CODE
$navigation->add_current_page();

Add below it ..
CODE
// FWRMedia mod to redirect to login when $_GET['cPath'] or $_GET['newsdesk_id'] is present and user not logged in
$logged_in = ( (tep_session_is_registered('customer_id')) ? true : false );
$redirect = ( (isset($_GET['cPath']) || isset($_GET['newsdesk_id'])) ? true : false );
( ($logged_in == false && $redirect == true) ? tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')) : false );
// End FWRMedia mod



Thank you for being so kind

Your script really worked out great!

wink.gif
fxtrader777
I am very ashamed to ask again a question

but if you do not mind I ask one


Everything worked great

but category's box behaves strange,

If unregister or register (result is the same for both) user clicks on any link in category box the result is the same: login box appears.

I restored default files (application_top.php) but it did not change.
fxtrader777
up up ....................................
fxtrader777
up
burt
and away.

Don't overcomplicate things. In product_info.php, find this:
CODE
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_INFO);
. Right below it, add this:
CODE
if (!tep_session_is_registered('customer_id')) {
    $navigation->set_snapshot(array('mode' => 'NONSSL', 'page' => FILENAME_PRODUCT_INFO));
    tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
  }
.
fxtrader777
QUOTE (burt @ Jan 11 2008, 05:00 PM) *
and away.

Don't overcomplicate things. In product_info.php, find this:
CODE
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_INFO);
. Right below it, add this:
CODE
if (!tep_session_is_registered('customer_id')) {
    $navigation->set_snapshot(array('mode' => 'NONSSL', 'page' => FILENAME_PRODUCT_INFO));
    tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
  }
.



Did it but nothing has changed

I think you are suggesting another thing

I have problem with categories box, Babygurgles knows what I mean, if he comes back hope will help

The problem is one cannot enter the link in categories box, no matter registered or unregistered. this is a problem, I would like to disble unregistered visitors to view categories box link but not registered users.
fxtrader777
I did it, I did it myself

yesssssss,

thanks everybody

I found a problem,
FWR Media
QUOTE (fxtrader777 @ Jan 11 2008, 05:14 PM) *
I did it, I did it myself

yesssssss,

thanks everybody

I found a problem,


I couldn't see any problem with my code .. what was it in the end?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.