function uc_coupon_autocomplete_user in Ubercart Discount Coupons 7.2
Same name and namespace in other branches
- 5 uc_coupon.module \uc_coupon_autocomplete_user()
- 6 uc_coupon.admin.inc \uc_coupon_autocomplete_user()
- 7.3 uc_coupon.admin.inc \uc_coupon_autocomplete_user()
Autocomplete callback for user restrictions.
1 string reference to 'uc_coupon_autocomplete_user'
- uc_coupon_menu in ./
uc_coupon.module - Implements hook_menu().
File
- ./
uc_coupon.admin.inc, line 926 - Discount Coupons administration pages.
Code
function uc_coupon_autocomplete_user($string) {
$matches = array();
$anonymous = t('anonymous users');
if (strpos($anonymous, $string) !== FALSE) {
$matches[$anonymous . ' [uid:0]'] = $anonymous;
}
$result = db_query("SELECT uid, name FROM {users} WHERE name LIKE :name", array(
':name' => "%{$string}%",
));
foreach ($result as $row) {
$matches[$row->name . ' [uid:' . $row->uid . ']'] = $row->name;
}
print drupal_json_encode($matches);
exit;
}