Drupal 6: Programatically add a user to an organic group when they register

I am working on an invitation system using organic groups and I needed the ability to programatically add a user to a (closed) organic group when they register for a new account. I tried to use the og_subscribe_user function, but it tests if the group allows registrations. In my situation the groups are closed, so I had to resort to the og_save_subscription function:

<?php
function MYMODULE_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'insert':

      // in my example, I'm querying a database for this number:
      $groupID = 'some number';

      og_save_subscription($groupID, $account->uid, array('is_active' => 1));
      break;
  }
}
?>

Updated: