Skip to content

Instantly share code, notes, and snippets.

@pifantastic
Created October 27, 2010 21:11
Show Gist options
  • Save pifantastic/650006 to your computer and use it in GitHub Desktop.
Save pifantastic/650006 to your computer and use it in GitHub Desktop.
<?php
/**
* Erase a CCK text field from a node.
*/
function el_commons_wipe_cck_text_field(&$node, $field_name) {
if (!isset($node->$field_name)) {
return;
}
foreach ((array) $node->$field_name as $i => $field) {
$node->$field_name[$i]['value'] = NULL;
}
}
/**
* Erase a CCK node reference field from a node.
*/
function el_commons_wipe_cck_nodereference_field(&$node, $field_name) {
if (!isset($node->$field_name)) {
return;
}
foreach ((array) $node->$field_name as $i => $field) {
$referenced_node = node_load($field['nid']);
if ($referenced_node->uid != $node->uid) {
$node->$field_name[$i] = NULL;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment