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),

Who is she ?

Say we have someone’s unique user id (uid), or possess some other information about her, and we wish to collect additional information, and this user is not currently the user that’s logged in (or browsing the web site anonymously), then what do we do ? We use the Drupal function user_load(), companion function of node_load()Read more →


Who am I ?

We can access a few variables from anywhere at anytime in Drupal, and the most important of these variables is $user. The object $user contains (almost) everything you’ll ever need to know about the user that is currently surfing the web site. Read more →


Drupal’s coder lost in space

Coder's guide to drupal's user and pathThis article is a coder’s apprentice guide to answering the question Who am I ? in drop all Drupal’s Content Management System, releases 5 and 6. While we’re at it, we’ll also answer the question Who is he or she ? with regards to any user — other than the one currently browsing the CMS. Finally, we’ll answer the question where are we ? as in : what is the “node” currently displayed on the page. Is there a node on the page, many, or none whatsoever ? Read more →


New DOM scripting book

[] This ebook comes in a PDF format, has 53 pages and is fully illustrated. The size of the file is approximately 2 MBytes. Attached are the table of content and a free sample of the book, containing these pages : the cover, the last page, and in between pages 1, 3, 23-25, 28, 30, 35, 37, 39-40, 43-45. The code for all exercises and two of the final exam questions are attached. Read more →

Because you are not logged in, you cannot see the 3 files attached to this posting. Login or register to download these files.