You are here

function realname_userref_autocomplete in Real Name 5

CCK Userref intercept; Change autocomplete suggestions to realnames.

1 string reference to 'realname_userref_autocomplete'
realname_menu in ./realname.module
Implementation of hook_menu().

File

./realname.module, line 297
The RealName module allows the admin to choose fields from the user profile that will be used to add a "realname" element (method) to a user object. Hook_user is used to automatically add this to any user object that is loaded.

Code

function realname_userref_autocomplete($field_name, $string = '') {
  $fields = content_fields();
  $field = $fields[$field_name];
  $matches = array();
  if ($string !== '') {
    $list = _userreference_potential_references($field, $string);
    foreach ($list as $uid => $name) {
      $account = user_load(array(
        'uid' => $uid,
      ));
      $matches[$name] = realname_make_name($account);
    }
  }
  print drupal_to_js($matches);
  exit;
}