User Custom Field in Node

Case[Node] node.tpl.php

$node_author = user_load($node->uid);
$user_lid = field_get_items('user', $node_author, 'field_user_id');
$user_photo = field_get_items('user', $node_author, 'field_user_photo');
<div class="node-photo">
 <?php if ($user_photo): ?>
  <img src="<?php print image_style_url('50x50', $user_photo[0]['uri']);  ?>" />
 <?php endif; ?>
</div>
<div class="node-lid">
 <?php render($user_lid[0]['value']) ?>
</div>

Case[Comment] comment.tpl.php

$comment_author = user_load($comment->uid);
$user_lid = field_get_items('user', $comment_author, 'field_user_id');
$user_photo = field_get_items('user', $comment_author, 'field_user_photo');
<div class="comment-photo">
<div class="comment-photo">
 <?php if ($user_photo): ?>
  <img src="<?php print image_style_url('50x50', $user_photo[0]['uri']);  ?>" />
 <?php endif; ?>
</div>
<div class="comment-lid">
 <?php print render($user_lid[0]['value']) ?>
</div>

Posted in Drupal