I need to edit a field in contentType B when I create or edit nodes of contentType A.
I know it's possible to use rules for this but I need to have more control so I want to do it in my own module.
Tried this code without success:
function MYMODULE_node_presave($node) {
MYMODULE_change_value($node);
}
function MYMODULE_change_value($node) {
$node = node_load($node->nid);
$referenced_nid = $node->referenced_node[LANGUAGE_NOE][0]['target_id']
$referenced_node = node_load(referenced_nid);
$referenced_node->my_field[LANGUAGE_NONE][0]['value'] = 12345.0;
node_save($referenced_node);
}
Am I choosing the wrong hook?