You are here

function og_field_delete_instance in Organic groups 7.2

Implements field_delete_instance().

  • Invalidate OG's static cache if a group-audience field is deleted.
  • Delete the default OG roles per entity-type and bundle.

File

./og.module, line 698
Enable users to create and manage groups with roles and permissions.

Code

function og_field_delete_instance($instance) {
  if (og_is_group_audience_field($instance['field_name'])) {
    og_invalidate_cache();
  }
  if ($instance['field_name'] != OG_GROUP_FIELD) {
    return;
  }

  // Get the per-bundle roles.
  $roles = og_roles($instance['entity_type'], $instance['bundle']);
  foreach ($roles as $rid => $name) {
    og_role_delete($rid);
  }
}