Membership Plugin Help

8 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: June 10, 2011   (RSS)

By KCMedia - June 7, 2011

Hi

I have started the process of designing the membership pages and have it so that the users can login to the site that works great but now i am stuck on how to only show each user the information on the page that they are allowed to see as each user is only allowed to see their childs information and no others.

Also with this site the members are added to the cms by the staff only there is no signup page or anything like that.

Can someone help me here is the url for the membership login

http://www.waggachildcare.com.au/kids-portfolio.php

the login is test and the password is test

i have also included the page that will show all the information that is required.

some help would be great thanks
Thanks



Craig

KC Media Solutions

www.kcmedia.biz
Attachments:

kids-homepage.php 12K

Re: [kcmedia] Membership Plugin Help

By Jason - June 7, 2011

Hi Craig,

I've taken a look at your page and it looks like you're off to a great start.

A couple of things I noticed to begin with:
- This piece of code here isn't needed:
// error checking
$errorsAndAlerts = alert();
if (@$CURRENT_USER) {
$errorsAndAlerts = "You are already logged in! <a href='{$GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL']}'>Click here to continue</a> or <a href='?action=logoff'>Logoff</a>.";
}


This code is usually only used on the login or forgotten password pages as it's meant to alert someone that they are currently logged in.

- Also, you're using "whereRecordNumberInUrl()" to fetch records for a number of sections (google_analytics, portfolio_meta, slogan, kids_name). Since there is no number in the url, it will only ever get the first record in the list. Typically, you only would ever use "whereRecordNumberInUrl()" on 1 section on a page. If any of these sections are single record sections, you can remove the "where" clause entirely since there will only ever be 1 record in that section.

That being said, what information are do you want to display about a particular child. How is this information stored and how is it related to the accounts section (ie, the person currently logged in)?

Let me know and we'll see if we can make some suggestions.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Membership Plugin Help

By KCMedia - June 7, 2011 - edited: June 7, 2011

Hi Jason

well i have 3 sections setup the best way would be for you to take a look at the CMS admin and see how i have set it up would that be alright.

but what i have is 3 multi sections

1 will store the kids name
1 will store a gallery
1 will store a diary

the gallery and diary both have a drop down list that gets the kids name from it to relate the records together based on the kids information.
Thanks



Craig

KC Media Solutions

www.kcmedia.biz

Re: [kcmedia] Membership Plugin Help

By Jason - June 8, 2011

Hi Craig,

How does a parent's user account related to the kid's records?

Let me know and we'll see what we can come up with.

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Membership Plugin Help

By KCMedia - June 8, 2011

Hi Jason

in the user account i created a drop down list that relates to the kids name so it shows a list of all kids added to the system.
Thanks



Craig

KC Media Solutions

www.kcmedia.biz

Re: [Jason] Membership Plugin Help

By KCMedia - June 9, 2011

Hi Jason

i did that but i keep getting errors on the page and still didnt work.

here is the code for the page.
Thanks



Craig

KC Media Solutions

www.kcmedia.biz
Attachments:

kids-homepage_001.php 12K

Re: [kcmedia] Membership Plugin Help

By Jason - June 10, 2011

Hi Craig,

I took a look and there are a couple of issues here.

- The field in the Accounts table is called "kids_portfolio", so this is the field you need to reference using $CURRENT_USER.
- In your where clause you need to specify which field you are searching against. For example:

'where' => "title = '".mysql_escape($CURRENT_USER['kids_portfolio'])."'",

- I noticed that you are using the "title" of field of the kids_name section as the value field in your list boxes. Although this is okay for a very small scale, it can cause certain problems. First, if you ever need to change the name of a child, it will break all of your associations. Also, if you have more than 1 child with the same name (ie, John Smith), then the parent of 1 child will be able to see records associated with the other. I would recommend using the "num" field as the value for the list options (you can still use title for the label without a problem). For information on how to set this up, see here: (http://www.interactivetools.com/kb/article.php?Populate-a-list-field-from-another-section-15)

That being said, you can structure your queries like this:

// load records
list($kids_diaryRecords, $kids_diaryMetaData) = getRecords(array(
'tableName' => 'kids_diary',
'where' => "kids_name = '".mysql_escape($CURRENT_USER['kids_portfolio'])."'",
'perPage' => '5',
));

// load records
list($kids_galleryRecords, $kids_galleryMetaData) = getRecords(array(
'tableName' => 'kids_gallery',
'where' => "kids_name ='".mysql_escape($CURRENT_USER['kids_portfolio'])."'",
'perPage' => '10',
));

// load records
list($kids_nameRecords, $kids_nameMetaData) = getRecords(array(
'tableName' => 'kids_name',
'where' => "title = '".mysql_escape($CURRENT_USER['kids_portfolio'])."'",
'limit' => '1',
));
$kids_nameRecord = @$kids_nameRecords[0]; // get first record


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/