You are here

function og_set_state_action in Organic groups 7.2

File

includes/actions/set_state.action.inc, line 32
Action to set the state of a user in a group.

Code

function og_set_state_action($og_membership, $context) {
  $state = $context['state'];
  if ($og_membership->state == $state) {
    return;
  }

  // Don't process the group manager, if exists.
  $group = entity_load_single($og_membership->group_type, $og_membership->gid);
  if (!empty($group->uid) && $group->uid == $og_membership->etid && $og_membership->entity_type == 'user') {
    return;
  }
  $og_membership->state = $state;
  $og_membership
    ->save();
}