I have a function that allows me to create users from the data of an external database:
function _loginuser_authenticate_validate($form, &$form_state) {
global $user;
// Use external database.
db_set_active('external_database');
// …
}
Now I want to create, for each user from the external database, two groups (each group with four Drupal users, a group administrator, and three normal members).
I can create a group with og_insert_group($node);
.
I can also create an admin for this group with og_save_subscription($node->nest, $node->uid, array ('is_active' => 1, 'is_admin' => 1));
.
I don't know how to create multiple groups, and add members to these groups. I also do not know where to put the code to create groups in the LoginUser module, or in another module.