function user_autocomplete

Same name and namespace in other branches
  1. 6.x drupal-6.x/modules/user/user.pages.inc \user_autocomplete()

Menu callback; Retrieve a JSON object containing autocomplete suggestions for existing users.

3 string references to 'user_autocomplete'
drupal-6.bare.database.php in drupal-7.x/modules/simpletest/tests/upgrade/drupal-6.bare.database.php
Bare installation of Drupal 6.17, for test purposes.
drupal-6.filled.database.php in drupal-7.x/modules/simpletest/tests/upgrade/drupal-6.filled.database.php
Filled installation of Drupal 6.17, for test purposes.
user_menu in drupal-7.x/modules/user/user.module
Implements hook_menu().

Archivo

drupal-7.x/modules/user/user.pages.inc, line 11
User page callback file for the user module.

Código

function user_autocomplete($string = '') {
  $matches = array();
  if ($string) {
    $result = db_select('users')->fields('users', array('name'))->condition('name', db_like($string) . '%', 'LIKE')->range(0, 10)->execute();
    foreach ($result as $user) {
      $matches[$user->name] = check_plain($user->name);
    }
  }

  drupal_json_output($matches);
}