Syndicate

Feed

user_load

Jul
02

Adding 'Last edited by name some time ago' information

Administrators are presented with a special marker when content is new or has been updated in the Administration section of their site at webSite.com/admin/content/node. Additionally, in node lists, the module tracker informs any logged-in user if he or she hasn't read a particular (recently created) node (using the marker new), or if a node he/she's read already was modified (using the marker updated). You, the themer, may want everyone, including “anonymous users”, to be informed of updates to nodes right inside their content. This information may specify who last edited the node and when. Note that the last editor of a content may not be the creator of that content, and I'll take this into account in my “solution”. In the following theming tweak, you'll add Last edited by name some time ago information to your nodes' content. Read more →

Feb
18

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),
  )
);
Feb
18

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 →

Feed