Search code examples
phpconcrete5

Concrete5 User attributes


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


Solution

  • After moving a little bit more around with the codes. i figured out that i just needed to move the

    $cobj->getCollectionUserID();
    

    into

    $ui = UserInfo::getByID($u->getUserID()); 
    

    So the finished code:

    <?php                   
     //Creat a UserInfo object with the Owner 
     $ui = UserInfo::getByID($cobj->getCollectionUserID() );  
     //Get the Value of your user Attribute  
     $value = $ui->getAttribute('name');  
     //Print it out  
     echo $value;  
    ?>