You are here

function userreference_field_formatter in Content Construction Kit (CCK) 5

Implementation of hook_field_formatter().

File

./userreference.module, line 110
Defines a field type for referencing a user from a node.

Code

function userreference_field_formatter($field, $item, $formatter, $node) {
  $text = '';
  if (isset($item['uid'])) {
    $referenced_user = user_load(array(
      'uid' => $item['uid'],
    ));
    if ($referenced_user) {
      $text = theme('username', $referenced_user);
    }
  }
  switch ($formatter) {
    case 'plain':
      return strip_tags($text);
    default:
      return $text;
  }
}