function realname_nodeapi in Real Name 5
Same name and namespace in other branches
- 6 realname.module \realname_nodeapi()
Implementation of hook_nodeapi().
3 string references to 'realname_nodeapi'
- realname_admin_settings in ./
realname.module - Displays the admin settings form.
- realname_admin_settings_submit in ./
realname.module - Form submit handler.
- realname_uninstall in ./
realname.install - Implementation of hook_uninstall().
File
- ./
realname.module, line 130 - The RealName module allows the admin to choose fields from the user profile that will be used to add a "realname" element (method) to a user object. Hook_user is used to automatically add this to any user object that is loaded.
Code
function realname_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
if (!user_access('use realname')) {
return;
}
if (!variable_get('realname_nodeapi', FALSE)) {
return;
}
switch ($op) {
case 'view':
// Node is being loaded.
// Save the username that is already there.
$node->realname_save = $node->name;
$account = user_load(array(
'uid' => $node->uid,
));
$node->realname = $node->name = realname_make_name($account);
$node->homepage = isset($account->homepage) ? $account->homepage : NULL;
break;
case 'prepare':
// Node is about to be edited.
// Reset the username or save will fail.
if (isset($node->realname_save)) {
$node->name = $node->realname_save;
}
break;
}
}