Drupal 6 : Programmatically creating nodes for OG..!

I am creating nodes pro-grammatically for a portal by fetching emails. But I have got a situation here.

I have some Organic group and every OG has got it's own content type. At start I thought to use different mailbox for each OG.

Now the thing is..how to assign nodes which get create pro-grammatically to particular OG ?

Note :- I am able to create different kind of nodes based on subject of the mail.

Please help..


When you are creating the node object set its og_groups property to an array of all the nids of the groups you want it in. For example if you have a group with nid 4, and you want your node to be in that group do this before calling node_save on it.

$node->og_groups = array(4);

After saving that node it should be in the og with nid 4.

Need Your Help

in drupal 7, how to submit a form without redirecting to the comment page or message page?

forms drupal redirect

I have made a message form and comment form as blocks and embedded the blocks in a view, whenever I submit the message / comment form, the page will redirect to the message / comment page.