You are here

function og_confirm_unsubscribe_submit in Organic groups 6

Same name and namespace in other branches
  1. 5.8 og.module \og_confirm_unsubscribe_submit()
  2. 5 og.module \og_confirm_unsubscribe_submit()
  3. 5.2 og.module \og_confirm_unsubscribe_submit()
  4. 5.3 og.module \og_confirm_unsubscribe_submit()
  5. 5.7 og.module \og_confirm_unsubscribe_submit()
  6. 6.2 og.pages.inc \og_confirm_unsubscribe_submit()

Confirm og unsubscription submit handler

File

./og.module, line 1095

Code

function og_confirm_unsubscribe_submit($form, &$form_state) {
  global $user;
  $group_node = $form_state['values']['group_node'];
  $account = $form_state['values']['account'];
  og_delete_subscription($group_node->nid, $account->uid);

  // If needed, reload user object to reflect unsubscribed group.
  if ($user->uid == $account->uid) {
    og_get_subscriptions($account->uid, 1, TRUE);

    // Clear cache.
    $user = user_load(array(
      'uid' => $user->uid,
    ));
  }
  drupal_set_message(t('%user removed from %group.', array(
    '%user' => $account->name,
    '%group' => $group_node->title,
  )));

  // Determine where to go next. GHP if accessible, or else site front page.
  $form_state['redirect'] = node_access('view', $group_node) ? "node/" . $group_node->nid : '';
}