Make almost duplicate copy of node when submitting We have a meeting room booking system that needs one extra feature added. Meeting rooms 1 and 2 have a removable wall so people can book Room 1, Room 2 or Rooms 1 and 2. What I need is a way during booking for the option to book one or both rooms. 

My plan: Offering separate booking forms for Room 1 and Room 2 and just have a field where they can check off if they need the other room booked with it. If this box is checked, it will create a duplicate booking with a new ID and the room number (Term reference list) changed. 

From my reading, I think I need to use node_save() to do this? I am not sure where to call this from though. I assume I need to call it from one of the hook_node_* things (as we already do for some other custom code)?

Basically, how do I create a duplicate node when submitting a form with almost identical data but one field is changed before it saves the copy?

Thanks!
Drupal core doesn't provide hook after a node has been saved, but you can use hook_node_presave() like

&lt;?php
function mymodule_node_presave() {
  $var = $node-&gt;original-&gt;field_my_field['und'][0]['value']; 
  // field_my_field could be the checkbox value, if both rooms should be booked
  if ($var == true) { make_a_copy_but_change_a_value(); }
}
?&gt;


Using this hook, you can look for your extra checkbox value (if the second room should be booked, too) and create a copy of the node object. But beware, at this point (hook_node_presave) the original node is not yet fully written to the database. However, the cool thing is that it fires both on node save and node update, so if you need to do something both on the creation and the updating of a node (e.g. if a booking of both rooms changes).

To actually use a hook after node insertion, you may want to try the Hook Post Action module as it provides special hooks. Drupal core does not provide such hooks, hook_node_insert and hook_node_update are both fired after the sql query for insertion is scheduled for execution but due to the transactional system the data is not yet in the database.