Load user fields in node.tpl.php

If you want load user fields like full name of author in node.tpl.php use the function: user_load($user->uid) then print_r the resulting object you will see how to access the info you need.

  1. <?php
  2. $node = $variables['node'];
  3. $author = user_load($node->uid);
  4. $full_name = field_get_items('user', $author, 'field_fullname');
  5. $userid = $node->uid;
  6. ?>

For author profile info on the node:

  1. <?php if ($full_name) : ?>
  2. <div class="author">
  3. <label class="inline">Full name:</label>
  4. <?php print render($full_name[0]['value']); ?>
  5. </div>
  6. <?php endif; ?>


Article Information
Article ID Categories Tags Levels Status
#22
Free
Solved