Skip to content

Instantly share code, notes, and snippets.

@cafuego
Created June 26, 2012 06:32
Show Gist options
  • Save cafuego/2993779 to your computer and use it in GitHub Desktop.
Save cafuego/2993779 to your computer and use it in GitHub Desktop.
static flag to avoid loop
wibble_node_presave($node) {
if (node->type == 'whatever') {
static $edit_flag;
if (reference_has_changed && empty($edit_flag)) {
$edit_flag = TRUE;
$reference = node_load($node->reference_field[0]['nid']);
$reference->reference_field[0]['nid'] = node->nid;
node_save($reference);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment