Fetch user related data

I use this function on functions.php in all my development websites

function imp($a){
  echo '<pre>';
  print_r($a);
  echo '</pre>';
  die();
}

now just use imp($user); where you are using get_user_meta ($user->ID).
you will have all the info about the $user, maybe this will tell you the answer you need…

You will find inside an object with ‘ID’, that’s why you can call $user->ID, if it were an array was possible to call $user[‘ID’].
normally with this function you can get all the info, sometimes are needed wordpress functions to get the info e.g. $user->get_ids(). but normally it is not needed.