user_autocomplete

Definition

user_autocomplete($string)
modules/user.module, line 2152

Description

Retrieve a pipe delimited string of autocomplete suggestions for existing users

Code

<?php
function user_autocomplete($string) {
  $matches = array();
  if ($string) {
    $result = db_query_range("SELECT name FROM {users} WHERE LOWER(name) LIKE LOWER('%s%%')", $string, 0, 10);
    while ($user = db_fetch_object($result)) {
      $matches[$user->name] = check_plain($user->name);
   }
  }
  print drupal_to_js($matches);
  exit();
}
?>
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.