function user_autocomplete
Menu callback; Retrieve a JSON object containing autocomplete suggestions for existing users.
1 string reference to 'user_autocomplete'
- user_menu in modules/
user/ user.module - Implements hook_menu().
File
-
modules/
user/ user.pages.inc, line 11
Code
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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.