uid && $gids = og_register_get_groups()) { $options['content groups'] = array_merge($options['content groups'], $gids); } } /** * Implement og_fields_info(). */ function og_register_group_fields_info() { $allowed_values = array( 0 => 'Do not show on registration page', 1 => 'Show on registration page', ); $items[OG_REGISTER_FIELD] = array( 'type' => array('group'), 'description' => t('Add Group register field group types.'), 'field' => array( 'field_name' => OG_REGISTER_FIELD, 'no_ui' => TRUE, 'type' => 'list_boolean', 'cardinality' => 1, 'settings' => array('allowed_values' => $allowed_values, 'allowed_values_function' => ''), ), 'instance' => array( 'label' => t('Groups register'), 'default_value' => array(0 => array('value' => 0)), 'widget_type' => 'options_select', 'view modes' => array( 'full' => array( 'label' => 'above', 'type' => 'options_onoff', ), 'teaser' => array( 'label' => 'above', 'type' => 'options_onoff', ), ), ), ); return $items; } /** * Get all the groups node IDs that should appear in the user registration. */ function og_register_get_groups() { $gids = &drupal_static(__FUNCTION__, array()); if (!$gids && $field = field_info_field(OG_REGISTER_FIELD)) { $conditions = array( array('og_register_value', 1), ); $query = new EntityFieldQuery; $result = $query ->fieldCondition(OG_REGISTER_FIELD, 'value', 1, '=') ->execute(); if ($result) { foreach ($result as $entity_type => $ids) { $ids = array_keys($ids); // Get the group IDs of the IDs. $gids = array_merge($gids, og_get_group_ids($entity_type, $ids)); } } } return $gids; }