Syndicate

Feed

Who authored this node?

Say we have a node ID (nid), and we want to know who authored the Drupal node with that ID, and that author is not currently the user that’s logged-in, then we use the Drupal function node_load(). (The companion function to user_load()). The function node_load() either accepts a numerical value which is the nid of the node, OR it accepts an associative array containing information about the node, criteria against which the function will try to find a match, in the database. The function returns a node object. One property of this object is uid, that is, the user ID of the author of the node, and another is name, and that's the name of the author. Say we want to find the e-mail address of the author of node with node ID 25:

/* Using node_load with a node ID parameter */
$node = node_load(25);
/* Then using user_load with the user ID */
$user = user_load(array('uid' => $node->uid));
print t('You may e-mail @name at !mailURL.',  array(
  '@name' => $user->name,
  '!mailURL' => l($user->mail, 'mailto:' . $user->mail),
  )
);

Browse this article

Last edited by Caroline Schnapp about 13 years ago.

Comments

Drupal Goddess

You are a god damned Drupal Goddess... I throw digital flowers at your feet.
Your tutorials have taught me more in five minutes than three months of stumbling through the drupal.org forums.

In the lots of cases Drupal

In the lots of cases Drupal site sux((
Users ask same questions from year to year, no good FAQ or standard tutorials (how to make catalog using taxonomy for example...)
That's why I love blogs like 11heavens :)

THank you for the post. The

THank you for the post. The site is just simply beautiful.

Thanks

Thanks, Simple and effective. Will this work with Drupal 6?

Sure

It should work as is in Drupal 6.

Just what I was looking for,

Just what I was looking for, thanks!

Drupal tutorials

Thanks for your Drupal tutorials. My drupal knowlege have improved more and more from reading your blog posts.

Thanks!

Thanks for posting this, it helped me out!

Thanks Jed!

:-)

Excellent! Concise, to the

Excellent! Concise, to the point and pretty damn useful.

Cheers!

hi to all , really helpfull post

exactly i needed .
It saves my time , Thanks to the author

You saved the day

Doing some drupal 7 hacking and this came to great use. thanks

These days I am reading a

These days I am reading a lot about this topic because I have my essay writing project due on this weekend, I am glad that i found some very useful information and great help to complete my assignment on time, Thanks a lot.

Cite Tags

potential Drupal 7 errors

This might throw up fatal array_flip errors in D7 because user_load() doesn't like arrays any more. Just use $node_uid instead:
$user = user_load( $node->uid);

Moreover, the awareness

Moreover, the awareness related to to its best. million diluted weighted fair shares outstanding & unusual. Vendors combined with web designers have got towards realization lots of of the bettering demand from customers intended for specialist http://1amon.com services out of giant size sneakers. executing helps about going for walks, low-priced ralph Lauren tennis games and as a consequence grounder. disagreeable kid wine drinks is created straight in to muscles, which may be applied to get producing clothes after which you can house textiles.

The condo’s facilities

The condo’s facilities provide full family entertainment needs for your family and loved ones. Indulge in a serene and tranquil lifestyle right in the heart of Tampines. new condo project