How would you programmatically create an OG group? I have tried
node_save() but to no joy.
It's simpler than attaching node as group post:
<?php global $user; $node = new stdClass(); $node->type = 'group'; // Change this to group node type name. $node->uid = $user->uid; $node->title = t('Title'); // Change title generation $node->body = t('Body'); // Change body generation $node->og_description = t('Group description'); // Change group description generation $node->og_selective = OG_CLOSED; $node->og_register = OG_REGISTRATION_NEVER; $node->og_directory = OG_DIRECTORY_CHOOSE_FALSE; $node->og_private = 0; node_save($node); og_insert_group($node); og_save_subscription($node->nid, $node->uid, array('is_active' => 1, 'is_admin' => 1));
(ofcourse you also need to check the return values from alle the three functions)
I don't really understand the question, but I created a lot of groups using the Mass Create module.
I was in the same struggle, but I realized that to create a new OG group programatically, the Rules module could be the key.
If you look for the right trigger and conditions, the first action would be "Entities > Create a new entity >OG group.
You can use the Rules scheduler to do the timing, if necessary.