make page membership plugin ready

3 posts by 2 authors in: Forums > CMS Builder
Last Post: August 13, 2012   (RSS)

By jimmy.g - August 13, 2012

Hi,
I've page liste_vitrine.php where it show every listing listed on database.
What i want is this page to show only the record of the current logged user
by example if I'm connected as john I want it to show only john record and vice versa.

So my question is how to do what I want to do and how to make a page work with the membership plugin I tried several thing on the CMSCookbook website but it seem that I'm a bit retard and cant get it to work :\

Thanks for your help by advance

Have a nice day

ps: I also want the page to be password protected by example if a person reach the page and is not connected I want the person to be redirected on the administration login page
Attachments:

liste_vitrine.php 2K

Re: [jimmy.g] make page membership plugin ready

By gkornbluth - August 13, 2012 - edited: August 13, 2012

Hi Jimmy,

To allow a user to see only his or her own records you might try something like this inside your foreach loop:
<?php if ($record['createdByUserNum']== @$CURRENT_USER['num']): ?>

Your record listing code goes here

<?php endif ?>


To restrict access to the page to registered users only you might try this after the load records code at the top of your page. It will direct visitors to your login page before they can access the restricted page:

<?php if (!$CURRENT_USER) { websiteLogin_redirectToLogin(); } ?>

Hope that gets you going.

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php