How to get the current viewed users uid
If you are showing a standard drupal user profile page this should get you going:

  $user = user_load(arg(1));
  $user-&gt;uid; // access user id


This assumes the path is user/uid. If your path looks different adjust the arg(position_in_path) to your needs.