Display user attribute

Permalink
Hello

I figured out how to du this seperatly

Display the user attribute:
<?php
//Create a User object (of the current User)
$u = new User();
//Creat a UserInfo object with the user ID
$ui = UserInfo::getByID($u->getUserID());
//Get the Value of your user Attribute
$value = $ui->getAttribute('name');
//Print it out
echo $value;
?>

Display page owner:
<?php
$ownerID = $cobj->getCollectionUserID();
$uia = UserInfo::getByID($ownerID);
$ownerName = $uia->getUserName();
echo $ownerName
?>

But i cannot figure out how to put them together so it displays the attribute('name'); of the page owner

Can you guys please help

Thanks

 
mckoenig replied on at Permalink Reply
mckoenig
I don't really get what the problem is. If you have the UserInfo object of the page owner you can fetch the name of the user (if the attribute exists) just the way you did in your first example.
Shotster replied on at Permalink Reply
Shotster
I think you just need to pass the page's owner ID to the getByID() method of the UserInfo class, like...

$ui = UserInfo::getByID($cobj->getCollectionUserID());


-Steve
removemeplease replied on at Permalink Reply
removemeplease
I don't really understand the original question of combining two things, but I need help based on the title of this post.

I know how to display a custom attribute for a page. Now I am trying to figure out how to display a user attribute.

More specifically, I want to use a page attribute to define which user's attributes are being displayed.

But first things first... I just want to get a user attribute to show up on my site.

Here is a link to my site:http://advising.terry.uga.edu/index.php/accounting/...

See the empty blocks in the sidebar? That's where I want user information to show up. See the blocks below with contact information? That's just regular ol' content blocks. I want to automate this content based on user attributes.

Thanks for any helpful suggestions!
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
@dfo
Did you ever figure this out?
I have also been pondering how to display one of the page owners user attributes..
i.e. The page Owner has several user attributes such as his membership number, i can figure out to get the page owners ID but how to use that to display one of his own attributes on his members page is eluding me..
ConcreteOwl replied on at Permalink Best Answer Reply
ConcreteOwl
Well just after posting this I flushed my brain and used this,
$c = Page::getCurrentPage();
$uID = $c->getCollectionUserID();
$ui = UserInfo::getByID($uID);
print $ui->getAttribute('membership');
removemeplease replied on at Permalink Reply
removemeplease
This is very helpful. A step in the right direction. Thank you!
mehreenbaakza replied on at Permalink Reply
mehreenbaakza
THANK YOU this is just what I was looking for!!!!
ssdscott replied on at Permalink Reply
ssdscott
Thanks Weyboat! Saved the proverbial bacon!