autocomplete field show name pass uid to form
In your foreach you can add it

foreach ($return as $row) {
   $matches[$row-&gt;name . '[uid:' . $row-&gt;uid . ']'] = check_plain($row-&gt;name);
}


And in your submit handler you can find it with a simple preg_match like this one :

preg_match('/\[uid:(\d+)\]/', $form_state['values']['user_autocomplete'], $matches);
$uid = $matches[1];


Note that the $matches variable are not the same from the auto-complete part and the submit handler part.