Programmatically assign a node to an organic group is following my previous question which I have found the solution for Drupal 7, but I am now looking for the same issue in Drupal 6.
How can I programmatically assign a node to an organic group?
I have tried the following and neither of them worked (assuming $target_group
is the group ID that I want the $node to be assigned to).
$node->og_groups = array($target_group => $target_group); node_save($node);
$group = node_load($target_group); $node->og_groups[0] = $target_group; $node->og_groups_names[0] = $group->title;
What is the proper way to do this?