<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Aug 14, 2010, at 11:58 PM, Jacob Roufa wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Nevermind, figured out to use $account-&gt;name. This isn't documented at <a href="http://api.drupal.org">api.drupal.org</a>... Any idea why?<br><br><div class="gmail_quote">On Sun, Aug 15, 2010 at 12:34 AM, Jacob Roufa <span dir="ltr">&lt;<a href="mailto:jacob.roufa@gmail.com">jacob.roufa@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin-top: 0pt; margin-right: 0pt; margin-bottom: 0pt; margin-left: 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex; position: static; z-index: auto; ">
I've been trying to display the user's name in their profile with no luck... global $user; ($user-&gt;name); displays the currently logged in user... Everything I've read says either to use that or profile_load_profile($user); print $user-&gt;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?<br></blockquote></div></blockquote></div><br><div>$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:</div><div><br></div><div>$account-&gt;uid = 1337;</div><div>profile_load_profile($account);</div><div><br></div><div>I often set up a utility function in template.php that looks something like this:</div><div><br></div><div>function get_username_from_uid($uid) {</div><div>&nbsp;&nbsp;$q = "SELECT name FROM {users} WHERE uid = %d";</div><div>&nbsp;&nbsp;return db_result(db_query($q, $uid));</div><div>}</div><div><br></div><div>It's useful in corner cases.&nbsp;</div><div><br></div><div>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?</div><div><br></div><div>-D</div></body></html>