Membership Plugin Quick Question

By gsfriend - March 17, 2010

I am preparing to order the membership plugin for CMSB, but i have one point that I need some clarification on.

I'm setting up a site for a custom home builder and they want a private area where customers can login and see pictures of their home during the construction process and we as a place they can access documents that relate to that customer only.

My question is, can the membership plugin be easily configured to display UNIQUE content to the current member logged in? In my case, each customer would have their own unique files that I would only want them to have access to, not other clients.

Thanks in advance!
--------------

Scott Friend

Freelance Website Design

www.scottfriendwebsitedesign.com

Re: [gsfriend] Membership Plugin Quick Question

By Dave - March 17, 2010

Hi gsfriend,

Not automatically, but it's pretty easy to setup.

What the plugin does is make a global available on every page called $CURRENT_USER that has the record of the currently logged in user.

So a simple implementation would be to have a section called "homes" with a field called "ownerUserNum" which was a pulldown of customer names (with user num stored as the value in the database).

Then in your homes viewer you could have something like:
'where' => " ownerUserNum = {$CURRENT_USER['num']} ",

And only homes assigned to the currently logged in user would be shown.

Hope that makes sense. Let me know any questions.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Membership Plugin Quick Question

By gsfriend - March 17, 2010

Dave,

Thanks for the reply. So for my config I was thinking I would have a multi record section labeled HOMES as you suggested. Each record then, if I am understanding this right, would have all the fields I need (Title, Name, Content, File Uploads for Images, etc.) as well as a field that would allow me to choose which registered user (from the membership plugin) would be allowed to access that page (record).

Does that sound about right?
--------------

Scott Friend

Freelance Website Design

www.scottfriendwebsitedesign.com

Re: [gsfriend] Membership Plugin Quick Question

By Dave - March 17, 2010

Hi Scott,

Yes, that's right.

You can add a field with a pulldown of users to the "Homes" section like this:

Go to: Admin > Section Editors > Homes > Add Field
Field Label: Owner
Field Name: ownerUserNum
Field Type: list

Display As: Pulldown
List Options: Get options from database (advanced)
Section Tablename: Accounts
Values Field: num
Labels Field: fullname

Let me know how it goes. :)
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Membership Plugin Quick Question

By gsfriend - March 23, 2010

OK, I almost have everything working. However, when someone hits the protected page and they are not logged in, they hit a SQL error message instead of being bounced to the login page.

This is a link to the protected page and the error:

http://www.homesbyexcalibur.com/home_info.php

Here is my header code:

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
require_once "/home/ekfriend/public_html/cms/lib/viewer_functions.php";

list($homeownersRecords, $homeownersMetaData) = getRecords(array(
'tableName' => 'homeowners',
'where' => " home_owner_user = {$CURRENT_USER['num']} ",
'limit' => '1',
));
$homeownersRecord = @$homeownersRecords[0]; // get first record

list($settingsRecords, $settingsMetaData) = getRecords(array(
'tableName' => 'settings',
'limit' => '1',
));
$settingsRecord = @$settingsRecords[0]; // get first record

// show error message if no matching record is found
if (!$settingsRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}

?>
<?php if (!@$GLOBALS['WEBSITE_MEMBERSHIP_PLUGIN']) { die("You must activate the Website Membership plugin before you can access this page."); } ?>
<?php if (!$CURRENT_USER) { websiteLogin_redirectToLogin(); } ?>

--------------

Scott Friend

Freelance Website Design

www.scottfriendwebsitedesign.com

Re: [gsfriend] Membership Plugin Quick Question

By gsfriend - March 23, 2010

Nevermind, I figured it out. I wasn't loading the login redirect script before the rest of the code.

DUH!
--------------

Scott Friend

Freelance Website Design

www.scottfriendwebsitedesign.com

Re: [Dave] Membership Plugin Quick Question

By Codee - March 24, 2010 - edited: March 24, 2010

Dave,
for this piece you wrote:
Then in your homes viewer you could have something like:
'where' => " ownerUserNum = {$CURRENT_USER['num']} ",


how do we adjust it so that that user/owner AND the admin can view it? I would like the admin to be able to view all the records but the userOwner only view theirs. Thanks in advance.

Re: [Dave] Membership Plugin Quick Question

By Codee - March 24, 2010

Thanks Dave! I knew it would be simple...for you.