Website membership: content based on user
6 posts by 3 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: May 15, 2012 (RSS)
I created an extra field in my User Accounts section called "Assets", it's an upload field.
How can I restrict that each user only sees his uploads when logging in?
I already succesfully implemented the membership plugin...
But what goes between this
<?php if ($CURRENT_USER): ?>
???
<?php endif ?>
Re: [videopixel] Website membership: content based on user
By Jason - December 21, 2011
Since $CURRENT_USER doesn't retrieve any upload information, you need to have a separate query to retrieve that user's record and uploads
For example:
<?php if ($CURRENT_USER): ?>
<?php
list($accountRecord, $accountMetaData) = getRecords(array(
'tableName' => 'accounts',
'allowSearch' => false,
'limit' => 1,
'where' => "num = '".intval($CURRENT_USER['num'])."'",
));
$assets = array();
if ($accountRecord) {
$assets = $accountRecord[0]['assets'];
}
?>
<?php foreach ($assets as $upload): ?>
//output images
<?php endforeach ?>
<?php endif ?>
Hope this helps get you started.
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] Website membership: content based on user
Re: [videopixel] Website membership: content based on user
By videopixel - December 21, 2011 - edited: December 21, 2011
Just 1 last question about this topic:
Is it possible that the "Admin" can see all assets when logged in?
Re: [videopixel] Website membership: content based on user
By Jason - December 22, 2011
Sure, you could check for isAdmin. If the user is an admin, you could retrieve all user records and display the assets for everything returned:
<?php if ($CURRENT_USER['isAdmin']): ?>
// get all account records and display assets.
<?php endif ?>
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] Website membership: content based on user
By RGC - May 15, 2012
Thanks Jason