user_node_load
function user_node_load
user_node_load($nodes, $types)
Implements hook_node_load().
File
- modules/user/user.module, line 3684
- Enables the user registration and login system.
Code
function user_node_load($nodes, $types) { // Build an array of all uids for node authors, keyed by nid. $uids = array(); foreach ($nodes as $nid => $node) { $uids[$nid] = $node->uid; } // Fetch name, picture, and data for these users. $user_fields = db_query("SELECT uid, name, picture, data FROM {users} WHERE uid IN (:uids)", array(':uids' => $uids))->fetchAllAssoc('uid'); // Add these values back into the node objects. foreach ($uids as $nid => $uid) { $nodes[$nid]->name = $user_fields[$uid]->name; $nodes[$nid]->picture = $user_fields[$uid]->picture; $nodes[$nid]->data = $user_fields[$uid]->data; } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!user!user.module/function/user_node_load/7.x