Get user object within module
You're currently referencing the global $user object, then in the very next line you're overwriting it with a string (the username). So your global $user object is destroyed, and you will probably be logged out of the site (as well as the code not working as expected).

You're referencing the global user object in the correct way, but by default it isn't fully loaded (i.e. with fields attached, etc). To get the extra data you should use the user_load() function like so:

global $user;

// Get the fully loaded user object
$account = user_load($user-&gt;uid);

// Get the username. Make sure you don't override the global $user object here!
$username = $account-&gt;user.

// Get a field value.
$field_items = field_get_items('user', $account, 'field_foo');