how can I get the node ids of related nodes after the node has been deleted?

Comments

Snehal Brahmbhatt’s picture

You can use following code in "Execute custom PHP code" for Actions of Rule.

  $master_nid = $node_id;              # Set current node id here.
  $field_name = $ref_node_field;      # Set reference node field here.

  // Load the 'master' node
  $master_node = node_load($master_nid);

  // Get the node reference items attached to this node
  $items = field_get_items('node', $node, $field_name);

  // Loop through and grab the nids
  $nids = array();
  foreach ($items as $item) {
    $nids[] = $item['nid'];
  }

  print("<pre> :: Reference NIDs");
  print_r($nids);
  print("</pre>");

Hope this helps you.

Thanks,
Snehal Brahmbhatt | AddWeb Solution
https://www.drupal.org/user/3147795/track

nwom’s picture

Status: Active » Closed (duplicate)
Related issues: +#893750: Event: "Content is going to be deleted"