Hi,
I want to add the imagefield of my nodeprofile to the $user-object.
Therefore I created the following function:
function myProfiledataToUser_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL){
if ($node->type == 'uprofile' && $op == 'submit') {
$nodeowner = user_load(array('uid' => $node->uid));
$extra_data = array('pic' => $node->field_profilepic[0]['filepath']);
user_save($nodeowner, $extra_data);
}
This works quite well except of the fact that I have to update the nodeprofile TWO times to make the change happen.
Does one of you guys know what my problem is?
I use cck-version: 5.x-1.6-1
Thanks in advance.
Regards,
macco
Comments
Comment #1
jpetso commentedWild guess, but could it be that $node->uid is still 0 in $op='submit' when the node is first created, and that the associated user is only available when the 'insert' or 'update' op is called?
Comment #2
macco commentedThanks for your thought.
I testet this now with 'insert', 'update' und the global $user-object.
The behavior did not change.
Ragards,
Marco
Comment #3
dopry commentedno clue then... maybe you need to clear a cache somewhere... you're gonna have to debug this one on your own... You might also pay attention to the weight of your custom module in the system table... sometimes increasing the weight so it runs after other modules can help in these situations.
.darrel.