how to get correct user id on page I've added two custom fields to my user form - field_license and field_download_date. In my preprocess_page function, I'm doing this:

if(isset($vars['user'])) {
   $user_data = user_load($vars['user']-&gt;uid);
   error_log("userdata");
   error_log(print_r($user_data, 1));
}


I'm not trying to get the current user info, but a specific user. When I look at the error log, though, $user_data is printing out the info of the user I'm logged in as, not the user that's displaying on the page based on the URL (mysite.com/user/2). How do I get the data for the user based on the url?
For getting user based on current page, you can try to use $account = menu_get_object('user') code.
Var $account will contain user object.
Read more about this function here: https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_get_object/7