| Versions | |
|---|---|
| 4.7 | user_autocomplete($string) |
| 5 – 7 | user_autocomplete($string = '') |
Retrieve a pipe delimited string of autocomplete suggestions for existing users
modules/
<?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();
}
?>