You are here

function og_membership_insert_on_entity_presave in Organic groups 7

Create a new group membership on entity presave.

See also

og_entity_presave().

File

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

Code

function og_membership_insert_on_entity_presave($values = array()) {

  // Create a new group membership entity.
  list($id) = entity_extract_ids($values['entity type'], $values['entity']);
  $group_membership = og_membership_create($values['gid'], $values['entity type'], $id, array(
    'state' => $values['state'],
    'membership type' => $values['membership type'],
    'membership fields' => $values['membership fields'],
  ));
  $group_membership
    ->save();
}