Mulpitle logins

5 posts by 2 authors in: Forums > CMS Builder
Last Post: July 19, 2010   (RSS)

Re: [pgplast] Mulpitle logins

By Chris - July 19, 2010

Hi pgplast,

For 1 and 2 you can simply add some extra fields and set up a "profile" page (there's a sample profile page included with the Membership plugin.)

Depending on your definition of "log in," 3 could be very simple or fairly difficult. The easiest solution would be to have a password form protecting your user_account detail viewer with some simple PHP code to make sure the visitor has supplied the correct "visitor password" before displaying the profile.

It might look something like this:

list($accountRecords,) = getRecords(array(
'tableName' => 'accounts',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$accountRecord = @$accountRecords[0]; // get first record

if (!$accountRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}

$passwordSupplied = @$_REQUEST['visitor_password'];
$passwordSuccess = (@$_REQUEST['visitor_password'] == $accountRecord['visitor_password']);
?>

<?php if ($passwordSupplied && !$passwordSuccess): ?>
<p style="color: red;">Password incorrect! Please try again.</p>
<?php endif ?>

<?php if (!$passwordSuccess): ?>
<form action="?<?php echo http_build_query($REQUEST) ?>">
<input type="password" name="visitor_password" />
<input type="submit" />
</form>
<?php exit ?>
<?php endif ?>

<p>Thank you for supplying the correct password. Here's the information:</p>

<p>Field1: <?php echo htmlspecialschars($accountRecord['field1']) ?></p>
<p>Field2: <?php echo htmlspecialschars($accountRecord['field2']) ?></p>
<p>Field3: <?php echo htmlspecialschars($accountRecord['field3']) ?></p>
etc.


I hope this helps. Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Mulpitle logins

By pgplast - July 19, 2010

Hey Chris, thanks.

But does your solution suggest that the actual user (vs the "guest" user) would not be able to access the viewer page with his password?

In other words, could the member user get into the inerface to make changes in his record, while the guest with his own password, would just see a readonly viewer?

Thanks, (and sorry for being dim).

Re: [pgplast] Mulpitle logins

By Chris - July 19, 2010

Hi pgplast,

For simplicity, I was thinking you could have separate viewers, but it wouldn't be too hard to add an extra check to that viewer to see if the record belongs to the user who's currently logged in.

I'd recommend setting this up with separate viewers first, just to keep everything simple and the site structure easy to change, then combining viewers at the end when you have everything working the way you want.
All the best,
Chris

Re: [chris] Mulpitle logins

By pgplast - July 19, 2010

Thanks, Chris.