Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By default I've set my groups to private in og settings. I wish to automatically set "membership requests" in some new groups as "invite only". Logically, I figure I need to set the $node->og_selective value to "2". Here is the code I'm using in hook_nodeapi:
case 'load':
// Make OG Membership Requests "invite only"
if (arg(0) == 'node' && (arg(1) == 'add' || arg(1) == 'ognodeadd') && (arg(2) == 'group' || $_GET['type'] == 'group' || arg(2) == 'og_user_roles_subgroup' || $_GET['type'] == 'og_user_roles_subgroup')) {
$node->og_selective = OG_INVITE_ONLY;
drupal_set_message('Subgroup load. og_selective = ' . $node->og_selective);
}
I've tried the same code in hook_nodeapi('prepare') with the same results:
I see the drupal message I've set in my group add form which indicates the code is executing, but the displayed form does not have "invite only" ticked. In fact, nothing under "Membership requests" is ticked.
Any suggestions? Thanks.