Is there a way to make some EZ-Pages for logged in members only whilst some are available for guests?
Is there a way to make some EZ-Pages for logged in members only whilst some are available for guests?
This is not a built in feature to EZ-Pages at this time ...
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!
Possibly something the Zen-Cart team could work on for a future version. I am sure it couldnt be too hard.
Is there a way to make ALL ez-pages for members only (not half and half). If not I will just have to put the information in as a free download I guess.
Cheers,
Alex
You could customize the /includes/pages/page to not allow access unless logged in ...
I am not sure how obnoxious it might be ...
Change the code in the header_php.php file from this:
to read this:PHP Code:
// This should be first line of the script:
$zco_notifier->notify('NOTIFY_HEADER_START_EZPAGE');
Now when a link is clicked on to go to one of the pages the customer has to login ...PHP Code:
// This should be first line of the script:
$zco_notifier->notify('NOTIFY_HEADER_START_EZPAGE');
// if the customer is not logged on, redirect them to the login page
if (!$_SESSION['customer_id']) {
$_SESSION['navigation']->set_snapshot();
zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
}
NOTE: the spiders cannot login to read anything now ...
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!
Thanks for that, I might give it a go.
For someone who might see this page looking for a similar fix, I just made my Documents side box available only to members. All I did was this:
Put
[FONT=Courier New]if ($_SESSION['customer_id']) {[/FONT]
[FONT=Courier New]CODE FROM SIDEBOX FILE[/FONT]
[FONT=Courier New]}[/FONT]
[FONT=Courier New][/FONT]
[FONT=Courier New]Works nicely in my situation[/FONT]
Thanks for that tip Alex. I was looking for a way to have a specific link come up only if a member has logged in and that 'if' statement was exactly what I needed.
Seek (along with some trial and error) and ye shall find!
Here's what seems to work for my "would it be possible" question above.
In 'includes/modules/pages/page/header_php.php' look for the following code around line 22:
Right after that code paste this:Code:$ezpage_id = (int)$_GET['id']; if ($ezpage_id == 0) zen_redirect(zen_href_link(FILENAME_DEFAULT));
In this case, the ez-pages with id's 5,6,10, & 14 will be redirected to the login page. All other ez-pages will go straight to the page. If you need other pages, you'll have to remember to come back and add them manually. This could also be modified to redirect to just about any ZC page that you have. Just change the zen_href_link() to suit your needs.Code:// if you want certain ez-pages accessed by members only, redirect them to the login page if (($ezpage_id == 5 || $ezpage_id == 6 || $ezpage_id == 10 || $ezpage_id == 14) && !$_SESSION['customer_id']) { $_SESSION['navigation']->set_snapshot(); zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL')); }
I'm open to suggestions/corrections to this code since I'm no PHP programmer. Maybe this could be added in the next version so that it's controllable through 'admin/configuration/ez-pages settings' similar to where you have control of disabling headers, footers, and columns?
After sleeping, I realized that the above example is good only if you have a few ez-pages (in relation to your total number of ez-pages) that need protection. For instance, you have 4 ez-pages that need protection and you have 100 other ez-pages that you don't need protection for.
For my own purposes, I needed the opposite of that. Once I started adding to the 'if' statement with my page id's this morning, it dawned on me (no pun intended) that this was going to take forever. Duh! I have 100 ez-pages that need to be password protected and only a couple that don't. So here's what I came up with:
In this example, if I have 100 ez-pages, all of them will redirect to the login page except for the two with id's 48 and 49.Code:// all ez-pages will direct visitors to login unless the ez-page's id's are included in this 'if' statement if ($ezpage_id == 48 || $ezpage_id == 49) { } else if (!$_SESSION['customer_id']) { $_SESSION['navigation']->set_snapshot(); zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL')); }
Bookmarks