How can I create a web form automatically when an organic group is created? I would like to automatically create a webform when a new organic group node is created.

The webform should have predefined fields and trigger an email to the group administrator or a user in the group with a predetermined role.  Alternatively it could email an address filled out in a cck field on the group content type.

I tried using og_webform but couldn't figure out how to get it to create webforms for each group.
There is probably multiple was to this.  The way I see it is a custom module.

You want to use hook_nodeapi(&amp;$node, $op) in Drupal 6,  hook_node_insert($node) in Drupal 7.

You code would look like something like this 

CUSTOM_MODULE_NAME_nodeapi(&amp;node, $op) {
  switch ($op) {
    case 'insert':
       if ($node-&gt;type == 'group') {
         global $user;

         // Create new object.
         $node = new stdClass();

         // Set desired data and metadata as members in object.
         $node-&gt;type = 'predefine_webform_with_predefine_fields';
         $node-&gt;uid = $user-&gt;uid;
         $node-&gt;title = 'node title';
         $node-&gt;body = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit...';
         //... prefill other cck fields

         // Save the node
         node_save($node);

       }
       break;
     }
   }
}


(Code should look the same for Drupal 7, minus the switch case)