function og_create_field in Organic groups 7.2
Same name and namespace in other branches
- 7 og.module \og_create_field()
Create an organic groups field in a bundle.
Parameters
$field_name: The field name
$entity_type: The entity type
$bundle: The bundle name.
$og_field: (optional) Array with field definitions, to allow easier overriding by the caller. If empty, function will get the field info by calling og_fields_info() with the field name.
43 calls to og_create_field()
- generate-og-d7-content-update-7001.php in scripts/
generate-og-d7-content-update-7001.php - OgAccess::testOgAccessEntity in ./
og.test - Verify og_user_access_entity() returns correct value.
- OgAccessModeratedGroup::setUp in og_access/
og_access.test - Sets up a Drupal site for running functional and integration tests.
- OgAccessTestCase::setUp in og_access/
og_access.test - Sets up a Drupal site for running functional and integration tests.
- OgAccessTestCase::testGroupContentAccessDefault in og_access/
og_access.test - Group with access field and group content with default definition.
File
- ./
og.module, line 3370 - Enable users to create and manage groups with roles and permissions.
Code
function og_create_field($field_name, $entity_type, $bundle, $og_field = array()) {
if (empty($og_field)) {
$og_field = og_fields_info($field_name);
}
$field = field_info_field($field_name);
// Allow overriding the field name.
$og_field['field']['field_name'] = $field_name;
if (empty($field)) {
$field = field_create_field($og_field['field']);
}
$instance = field_info_instance($entity_type, $field_name, $bundle);
if (empty($instance)) {
$instance = $og_field['instance'];
$instance += array(
'field_name' => $field_name,
'bundle' => $bundle,
'entity_type' => $entity_type,
);
field_create_instance($instance);
// Clear the entity property info cache, as OG fields might add different
// entity property info.
og_invalidate_cache();
entity_property_info_cache_clear();
}
}