You are here

function og_membership_delete_on_entity_presave in Organic groups 7

Delete an existing group membership on entity presave.

See also

og_entity_presave().

File

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

Code

function og_membership_delete_on_entity_presave($values = array()) {

  // Delete group membership entity.
  list($id) = entity_extract_ids($values['entity type'], $values['entity']);

  // If the group is already deleted, all the group memberships were already
  // deleted.
  if ($group_membership = og_get_group_membership($values['gid'], $values['entity type'], $id)) {
    $group_membership
      ->delete();
  }
}