How to display part of an author's profile in a node

I have been trying to do display a custom field I created in the manage fields section of user accounts for nodes in addition to the profile page. The problem I am having with this code is that it will display the first field it finds and display that for every user, not the field for that particular user.
And ideas? I believe it's finding the first value in the array and not the value for the particular user in the array.


Here is m setup so far:
Added this to my template.php of my theme:

function mythemename_preprocess_node(&$vars) {

global $user;
  $user = user_load($user->uid); // Make sure the user object is fully loaded
  $team = field_get_items('user', $user, 'field_team');
  if ($team) {
    $vars['field_team'] = $team[0]['value'];
  }
}
Then, added this to my node.tpl.php in order to display it on nodes.

 if (isset($field_team) && !empty($field_team)) :
  echo '$field_team.'</div>';
endif;

Open in new window

adrian7474Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oliverpoldenCommented:
yes $team[0] gives you the first value.  You need to do something like

foreach ($team as $team_member) {
  $vars['field_team'] .= $team_member['value'];
}

Open in new window

0
adrian7474Author Commented:
Thanks, I ended putting this into my node.tpl.php file and it works great. I think with the above code I pasted before, it was an incorrect way to call the user global.




if($page){ 
   echo'  |  ';
  $node_author = user_load($node->uid);
  
  $team = $node_author->field_byline;
  if (isset($team['und'][0]['value'])) {
       print ($team['und'][0]['value']);
    }
	
   }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
adrian7474Author Commented:
Found my own solution.
0
oliverpoldenCommented:
No problem, glad you got it sorted.

Oliver - www.onlinemagnetism.com
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.