Get User's ID by a given username

One action we needed, was the ability to accept a username and attach the user to a call automatically. Without being able to ask the user to select from a list of users in the system, we have them give us the actual username.

This function will convert a username into a users id if they are in the system.

$user = new User;
$user_id = $user->retrieve_user_id($username);
echo $user_id;