Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 27
  1. #11
    Join Date
    Feb 2011
    Posts
    6
    Plugin Contributions
    0

    Default Re: Require Login for one EZ Page?

    thank that works perfectly. quick question tho is echo('Access.'); necessary?

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

    Default Re: Require Login for one EZ Page?

    no, I not even sure why its there, it could have been

    <?php
    if (in_array($_SESSION['customer_id'],explode(",",'1,4')) ) {
    echo('Access. 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.');}
    ?>

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

    Default Re: Require Login for one EZ Page?

    rbarbour,
    Always glad to learn something new. I like the way you used "in_array" and used the output from "explode" without assigning it to a variable. I might not have considered that option.

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

    Default Re: Require Login for one EZ Page?

    I know very little php, I know it worked, I don't know if it is the right way. Someone with a little more knowledge may be able to show an alternate option or way of doing it.

  5. #15
    Join Date
    May 2012
    Posts
    36
    Plugin Contributions
    0

    Default Re: Require Login for one EZ Page?

    I am trying to combine restrictions to ez pages based on ez page id and customer id. For example, I have 2 ez pages with id1 and id2. And 4 customers id1-id4. I want to restrict:

    ez page id 1 for only customer id 1 and 2
    ez page id 2 for only cusotmer id 3 and 4

    This is what I have, but does not work. Is it possible to restrict 2 ways or only 1 way?


    Code:
    if ($ezpage_id == 1) {
    if ($_SESSION['customer_id'] == "1" ) {
    if ($_SESSION['customer_id'] == "2" ) {
        $_SESSION['navigation']->set_snapshot();
        zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
      }
    }
    
    
    if ($ezpage_id == 2) {
    if ($_SESSION['customer_id'] == "3" ) {
    if ($_SESSION['customer_id'] == "4" ) {
        $_SESSION['navigation']->set_snapshot();
        zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
      }
    }
    Thanks

  6. #16
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Require Login for one EZ Page?

    You are blocking your self with your code ...

    Are you trying to make ezpage_id 1 only available to customers_id 1 and 2?

    Are you trying to make ezpage_id 2 only available to customers_id 3 and 4?

    What happens if the customer_id is 7 and they try to get to ezpage_1 ... where should they go?
    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: v1.5.5]
    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!

  7. #17
    Join Date
    May 2012
    Posts
    36
    Plugin Contributions
    0

    Default Re: Require Login for one EZ Page?

    Quote Originally Posted by Ajeh View Post
    You are blocking your self with your code ...

    Are you trying to make ezpage_id 1 only available to customers_id 1 and 2?

    Are you trying to make ezpage_id 2 only available to customers_id 3 and 4?

    What happens if the customer_id is 7 and they try to get to ezpage_1 ... where should they go?
    Bad on my part to not include a little more detail of what I have so far. Right now I have a second site which is only for my partnering distributors. I had to make a second site in a subfolder to make sure that the public cannot access the product prices. One common problem in many mods for previous versions such as "specific categories for specific customers" works, but if you were to change the product_id in the url to another number, it would show for that product, even if it wasn't assigned to them. Pretty much what I have done now is create ezpages with html code for the product info pages which now shows and works when adding to cart. So this leads to restricting the pages for certain distributors.

    I have my site using the setting in Admin-Config-Customer Details, both must login to browse and authorization both set to 1.

    Right now I only have 2 ezpages and 4 customers, which after I figure this coding out, I will use it to expand it to more ezpages and add the additional customers manually.

    Yes exactly, I only want those particular customers allowed to access the ezpage. So in the case of customer_id 7, they will be routed to a custom page I made saying the page is restricted (filename page_restricted).

    Thanks Ajeh
    Last edited by grantopt; 27 May 2012 at 12:48 AM.

  8. #18
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Require Login for one EZ Page?

    What I did was make an Ezpage with no setting for Sort Order, that is ezpage_id 17 in this code, and when someone logs in that is not allowed on the page based on $_SESSION['customer_id'] they are sent to this EzPage for ezpage_id 17 which reads that they are not a member ...

    I customized the code in:
    /includes/modules/pages/page/header_php.php

    and added the code in RED to control when the customer is not logged in and when the customer is allowed or not allowed to get to their EZPage ...
    Code:
    $chapter_id = (int)$_GET['chapter'];
    $chapter_link = (int)$_GET['chapter'];
    
    //die('I SEE ' . $ezpage_id . ' - ' . $group_id);
    //die('I SEE ' . $ezpage_id . ' - ' . $chapter_id);
    
    // bof: ezpages ezpage_id 16 only for customers_id 2 & 7 go to ezpage_id 17 if not correct customer when logged in
    if ($ezpage_id == 16) {
      if (!$_SESSION['customer_id']) {
        $_SESSION['navigation']->set_snapshot();
        $messageStack->add_session('header', 'Please login to access Member\'s area', 'caution');
        zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
      }
      if ($_SESSION['customer_id'] != 2 && $_SESSION['customer_id'] != 7) {
        $messageStack->add_session('header', 'Sorry you do not have access to Member\'s area', 'caution');
        zen_redirect(zen_href_link(FILENAME_EZPAGES, 'id=17', 'NONSSL'));
      }
    }
    // eof: ezpages ezpage_id 16 only for customers_id 2 & 7 go to ezpage_id 17 if not correct customer when logged in
    
    $var_pageDetails = $db->Execute("select * from " . TABLE_EZPAGES . " where pages_id = " . (int)$ezpage_id );
    In this case, the ezpage_id they are trying to get to is ezpage_id 16 ...

    If not logged in, they are asked to login before anything ...

    Once logged in, the $_SESSION['customer_id'] is tested and if NOT customers_id 2 or 7, they are sent to the ezpage_id 17 and told they are not a member ...

    If they are customers_id 2 or 7 then they can go on to ezpage_id 16 ...
    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: v1.5.5]
    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. #19
    Join Date
    May 2012
    Posts
    36
    Plugin Contributions
    0

    Default Re: Require Login for one EZ Page?

    Quote Originally Posted by Ajeh View Post
    What I did was make an Ezpage with no setting for Sort Order, that is ezpage_id 17 in this code, and when someone logs in that is not allowed on the page based on $_SESSION['customer_id'] they are sent to this EzPage for ezpage_id 17 which reads that they are not a member ...

    I customized the code in:
    /includes/modules/pages/page/header_php.php

    and added the code in RED to control when the customer is not logged in and when the customer is allowed or not allowed to get to their EZPage ...
    Code:
    $chapter_id = (int)$_GET['chapter'];
    $chapter_link = (int)$_GET['chapter'];
    
    //die('I SEE ' . $ezpage_id . ' - ' . $group_id);
    //die('I SEE ' . $ezpage_id . ' - ' . $chapter_id);
    
    // bof: ezpages ezpage_id 16 only for customers_id 2 & 7 go to ezpage_id 17 if not correct customer when logged in
    if ($ezpage_id == 16) {
      if (!$_SESSION['customer_id']) {
        $_SESSION['navigation']->set_snapshot();
        $messageStack->add_session('header', 'Please login to access Member\'s area', 'caution');
        zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
      }
      if ($_SESSION['customer_id'] != 2 && $_SESSION['customer_id'] != 7) {
        $messageStack->add_session('header', 'Sorry you do not have access to Member\'s area', 'caution');
        zen_redirect(zen_href_link(FILENAME_EZPAGES, 'id=17', 'NONSSL'));
      }
    }
    // eof: ezpages ezpage_id 16 only for customers_id 2 & 7 go to ezpage_id 17 if not correct customer when logged in
    
    $var_pageDetails = $db->Execute("select * from " . TABLE_EZPAGES . " where pages_id = " . (int)$ezpage_id );
    In this case, the ezpage_id they are trying to get to is ezpage_id 16 ...

    If not logged in, they are asked to login before anything ...

    Once logged in, the $_SESSION['customer_id'] is tested and if NOT customers_id 2 or 7, they are sent to the ezpage_id 17 and told they are not a member ...

    If they are customers_id 2 or 7 then they can go on to ezpage_id 16 ...
    Awesome. I thank you for the coding and it works like a charm. Much simpler to use an ezpage for a restricted page, tested and works perfectly now.

  10. #20
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Require Login for one EZ Page?

    Thanks for the update that this is working for you ...
    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: v1.5.5]
    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!

 

 
Page 2 of 3 FirstFirst 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