function og_ungroup in Organic groups 7.2
Same name and namespace in other branches
- 7 og.module \og_ungroup()
Delete an association (e.g. unsubscribe) of an entity to a group.
Parameters
$group_type: The entity type (e.g. "node").
$gid: The group entity object or ID, to ungroup.
$entity_type: (optional) The entity type (e.g. "node" or "user").
$etid: (optional) The entity object or ID, to ungroup.
Return value
The entity with the fields updated.
7 calls to og_ungroup()
- MigrateDestinationOGMembership::rollback in includes/migrate/ plugins/ destinations/ og_membership.inc 
- Delete a membership.
- OgGroupAndUngroup::testGroupAndUngroup in ./og.test 
- Test group and ungroup of content.
- OgRoleRevoke::testOgRoleRevoke in ./og.test 
- og_group in ./og.module 
- Set an association (e.g. subscribe) an entity to a group.
- og_rules_remove_entity_from_group in ./og.rules.inc 
- Action: Remove entity from group.
File
- ./og.module, line 2097 
- Enable users to create and manage groups with roles and permissions.
Code
function og_ungroup($group_type, $gid, $entity_type = 'user', $etid = NULL) {
  if (is_object($gid)) {
    list($gid) = entity_extract_ids($group_type, $gid);
  }
  if ($entity_type == 'user' && empty($etid)) {
    global $user;
    $etid = $user->uid;
  }
  elseif (is_object($etid)) {
    list($etid) = entity_extract_ids($entity_type, $etid);
  }
  if ($og_membership = og_get_membership($group_type, $gid, $entity_type, $etid)) {
    $og_membership
      ->delete();
  }
}