On this page
function user_autocomplete
user_autocomplete($string = '')
Menu callback; Retrieve a JSON object containing autocomplete suggestions for existing users.
File
- modules/user/user.pages.inc, line 11
- User page callback file for the user module.
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);
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!user!user.pages.inc/function/user_autocomplete/7.x