On Aug 14, 2010, at 11:58 PM, Jacob Roufa wrote:
Nevermind, figured out to use $account->name. This isn't documented at api.drupal.org... Any idea why?
On Sun, Aug 15, 2010 at 12:34 AM, Jacob Roufa <jacob.roufa@gmail.com> wrote: I've been trying to display the user's name in their profile with no luck... global $user; ($user->name); displays the currently logged in user... Everything I've read says either to use that or profile_load_profile($user); print $user->name; but neither are working and I can't figure out how to use the $account variable either. This is with Drupal 5. Any suggestions?
$user is always the current user object. profile_load_profile() is sort of an awkward way to get the user's name since it operates by reference: $account->uid = 1337; profile_load_profile($account); I often set up a utility function in template.php that looks something like this: function get_username_from_uid($uid) { $q = "SELECT name FROM {users} WHERE uid = %d"; return db_result(db_query($q, $uid)); } It's useful in corner cases. In your case (on a profile page), $account should already be populated with what you need. print_r() it and make sure you're not missing it? -D