Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder: Plugins & Add-ons:
Website membership: content based on user

 

 


videopixel
User

Dec 21, 2011, 5:17 AM

Post #1 of 6 (954 views)
Shortcut
Website membership: content based on user Can't Post

Hello,

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


Code
<?php if ($CURRENT_USER): ?> 
???
<?php endif ?>



Jason
Staff / Moderator


Dec 21, 2011, 9:38 AM

Post #2 of 6 (943 views)
Shortcut
Re: [videopixel] Website membership: content based on user [In reply to] Can't Post

Hi,

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:


Code
<?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 - Programmer 
interactivetools.com

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


videopixel
User

Dec 21, 2011, 10:13 AM

Post #3 of 6 (941 views)
Shortcut
Re: [Jason] Website membership: content based on user [In reply to] Can't Post

THANKS! Jason


videopixel
User

Dec 21, 2011, 3:52 PM

Post #4 of 6 (935 views)
Shortcut
Re: [videopixel] Website membership: content based on user [In reply to] Can't Post

Everything works Jason...

Just 1 last question about this topic:

Is it possible that the "Admin" can see all assets when logged in?


(This post was edited by videopixel on Dec 21, 2011, 3:53 PM)


Jason
Staff / Moderator


Dec 22, 2011, 12:02 PM

Post #5 of 6 (915 views)
Shortcut
Re: [videopixel] Website membership: content based on user [In reply to] Can't Post

Hi,

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:



Code
<?php if ($CURRENT_USER['isAdmin']): ?> 
// get all account records and display assets.
<?php endif ?>


Hope this helps
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

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


rgc
User

May 15, 2012, 12:13 PM

Post #6 of 6 (72 views)
Shortcut
Re: [Jason] Website membership: content based on user [In reply to] Can't Post

I was looking for code that would display a members business logo when logged into the membership section of the web site. This code did the trick.

Thanks Jason