How to create node in hook_node_insert without triggering it recursively I have a situation where I need to create node(s) in hook_node_insert for certain dates.

Details: There is a content type with date field (start and end-date enabled). The requirement is to create the node with same contents for those many dates.

For example, if the date is from Mar5, 2014 to Mar8, 2014. I need to create node with Startdate &amp; Enddate: Mar5 for one node and Startdate &amp; Enddate: Mar6 for the next node and so on till Mar8 is assigned as start &amp; enddate for the last node.

I got stuck with infinite loop. How do I solve this?
Why not add a second submit handler using hook_form_alter to the node add form and put your functionality in there as opposed to using hook_node_insert?

That way the code will run everytime the node add form is submitted, but you won't get into the endless loop scenario...