By macco on
Hello,
I created user a user profile for my site with the Node Profile module. This profile has
one field for the first name and one for the last name of the user.
I would like to add this piece of information to the $user-object.
My approach was to do this in a module via the "user_save()" function:
function uprofile_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
.
.
.
case 'update':
if ($node->moderate && user_access('access submission queue')) {
drupal_set_message(t('The post is queued for approval'));
}
elseif ($node->moderate) {
drupal_set_message(t('The post is queued for approval. The editors will decide whether it should be published.'));
}
// I added this piece of code
global $user;
if ($user->uid == $node->uid) { // Only change something in $user-object of the profile's owner
$firstname = array ('firstname' => $node->field_firstname[0]['value']);
$lastname = array ('lastname' => $node->field_lastname[0]['value']);
$fullname = array ('fullname' => ($node->field_firstname[0]['value'] . " " . $node->field_lastname[0]['value']));
user_save($user,$firstname);
user_save($user,$lastname);
user_save($user,$fullname);
}
break;
.
.
.
Unfortunately my module doesn't add anything to the $user-object.
Can anybody tell me if I should use another hook or if my total approach is wrong.
Regards,
Marco