Page 1 of 3 123 LastLast
Results 1 to 10 of 27
  1. #1
    Join Date
    Nov 2006
    Posts
    6
    Plugin Contributions
    0

    Default Require Login for one EZ Page?

    A new zenner with my first question! Not sure what section thsi should be posted under, so I'm starting here.

    Incidentally, this forum has been FANTASTIC so far and I've found an answer to nearly every question I've had, but I can't find this one.

    I'm a designer who just took my first store site live, and so far eveything is working great. But I'm wondering if there is a way to require a customer to login/create an account to access just ONE of the EZ pages I have set up (In Store Coupons! page). We have coupons that can be printed and use in our brick and mortar store, and I'd like to require customers to set up an account before accessing the coupons. I don't want people to have to login to see the other EZ pages.

    I'm guessing it's an " if ($_SESSION..." statement placed somewhere, but my overall knowledge of php is very limited - anyone have suggestions?

    And any other site critique is appreciated also...

    Thanks
    R Fish

    http://monsterpawn.com

  2. #2
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Require Login for one EZ Page?

    /includes/modules/pages/page/header_php.php
    around line 23 you'll see:
    Code:
    if ($ezpage_id == 0) zen_redirect(zen_href_link(FILENAME_DEFAULT));
    Right below that, insert the following code, substituting '55' with the number of the page to 'protect':
    Code:
    if ($ezpage_id == 55) {
      if (!$_SESSION['customer_id']) {
        $_SESSION['navigation']->set_snapshot();
        zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
      }
    }
    .

    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.

  3. #3
    Join Date
    Feb 2005
    Posts
    246
    Plugin Contributions
    0

    Default Re: Require Login for one EZ Page?

    You could instead follow the advice of post 7 on this thread: allow php inside ezpages

    and then put this in any ezpage to allow more than one "members only" page without needing to edit the header_php.php file for each one.

    PHP Code:
    <?php
    if ($_SESSION['customer_id']) {
    echo(
    'You are signed in and have access to the members only area.');
    }else{echo(
    'You are not signed in, and do not have access to the members only area.');}
    ?>
    (In case it isn't obvious, put your members only content where I have the first echo, and replace the second echo if you want a different message to ask them to sign in.)

  4. #4
    Join Date
    Feb 2010
    Posts
    6
    Plugin Contributions
    0

    Default Re: Require Login for one EZ Page?

    In the code:

    <?php
    if ($_SESSION['customer_id']) {
    echo('You are signed in and have access to the members only area.');
    }else{echo('You are not signed in, and do not have access to the members only area.');}
    ?>

    Is it possible to specify a specific customer_id ? Like only show this page to customer id # 1?

    Thanks,
    Kristina

  5. #5
    Join Date
    Feb 2010
    Posts
    6
    Plugin Contributions
    0

    Default Re: Require Login for one EZ Page?

    I did it! For those who would like to know how to hide a page for logged in members AND only give access to a select member or members.

    Insert this in an ezpage: (to learn how to insert php in an EZpage, look at the link above)

    <?php
    if ($_SESSION['customer_id'] == "1" ) {
    echo('Access.');
    }else{echo('You are not signed in, and do not have access to the members only area.');}
    ?>

    Change number "1" to the customer number you want to have access to the page. You can find your customer number by going to "customers" in the admin section of your Zen Cart. The number is right next to the listing.

    Obviously, change the echo'' to the statement you want your logged in member to see.

  6. #6
    Join Date
    Oct 2006
    Posts
    1
    Plugin Contributions
    0

    Default Re: Require Login for one EZ Page?

    I have the site set up so a customer must login to see the products, but this also locks them from the ezpages is there a way to allow new customers that have not set up an account to view the ez pages?

  7. #7
    Join Date
    Feb 2011
    Posts
    6
    Plugin Contributions
    0

    Default Re: Require Login for one EZ Page?

    how can you add more that one id

  8. #8
    Join Date
    Feb 2010
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: Require Login for one EZ Page?

    not sure this is the right code but it works.

    <?php
    if ($_SESSION['customer_id'] == "1" ) {
    if ($_SESSION['customer_id'] == "4" ) {
    echo('Access.');
    echo('You are signed in and have access to the members only area.');
    }else{echo('You are not signed in, and do not have access to the members only area.');}
    ?>

    have to keep duplicating 'if' statement

  9. #9
    Join Date
    Feb 2011
    Posts
    6
    Plugin Contributions
    0

    Default Re: Require Login for one EZ Page?

    thx i wasn't sure it that would work, ill use it unless something else works better. im not as fluent in php yet i think it mite be possible to do an array. but i could be wrong.

  10. #10
    Join Date
    Feb 2010
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: Require Login for one EZ Page?

    disregard first post, try this:

    <?php
    if (in_array($_SESSION['customer_id'],explode(",",'1,4')) ) {
    echo('Access.');
    echo('You are signed in and have access to the members only area.');
    }else{echo('You are not signed in, and do not have access to the members only area.');}
    ?>

    separated_by_commas,and_no_spaces

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. v151 Require Login for Certain Categories or Products
    By clausont in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 6 Jun 2013, 01:41 PM
  2. NOT require login to view EZ Page from Banner Link
    By dimsumgurl in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 29 Apr 2011, 04:00 PM
  3. want 2 login pages - one for check out, one for login
    By vandiermen in forum All Other Contributions/Addons
    Replies: 6
    Last Post: 11 Aug 2007, 07:34 PM
  4. Require Login for Certain Pages
    By samad64 in forum General Questions
    Replies: 5
    Last Post: 26 Jun 2007, 03:31 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR