Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Mar 2005
    Posts
    123
    Plugin Contributions
    0

    Default 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

  2. #2
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,269
    Plugin Contributions
    3

    Default 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

  3. #3
    Join Date
    Mar 2005
    Posts
    123
    Plugin Contributions
    0

    Default 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

  4. #4
    Join Date
    Mar 2005
    Posts
    123
    Plugin Contributions
    0

    Default 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...?

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

    Default 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:
    Code:
    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!

  6. #6
    Join Date
    Mar 2005
    Posts
    123
    Plugin Contributions
    0

    Default Re: Link only show when logged in

    That worked great - thanks Ajeh! :)

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

    Default 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 ...
    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!

  8. #8
    Join Date
    Dec 2009
    Location
    Canada
    Posts
    160
    Plugin Contributions
    0

    Default 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. #9
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Link only show when logged in

    You would need to manage your links with something like:
    Code:
    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!

  10. #10
    Join Date
    Dec 2009
    Location
    Canada
    Posts
    160
    Plugin Contributions
    0

    Default 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?

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v150 Show Product Description only when logged in
    By fsu711 in forum Templates, Stylesheets, Page Layout
    Replies: 8
    Last Post: 4 Apr 2012, 11:57 PM
  2. E-Z Pages To Only Show When Logged in??
    By mattk251285 in forum Templates, Stylesheets, Page Layout
    Replies: 23
    Last Post: 14 Dec 2011, 06:25 PM
  3. I want to show only certain menu items when not logged in
    By gbruner in forum General Questions
    Replies: 0
    Last Post: 27 Oct 2010, 04:20 AM
  4. Replies: 18
    Last Post: 29 Sep 2009, 02:37 PM
  5. log off link - how do I make it only appear when logged on?
    By gsdcypher in forum General Questions
    Replies: 23
    Last Post: 2 Apr 2008, 12:28 AM

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