You are here

function og_ui_og_user_access_alter in Organic groups 7

Same name and namespace in other branches
  1. 7.2 og_ui/og_ui.module \og_ui_og_user_access_alter()

Implements hook_og_user_access_alter().

Add a permission to pending users to unsubscribe form group.

File

og_ui/og_ui.module, line 297
Organic groups UI.

Code

function og_ui_og_user_access_alter(&$perms, $context) {
  if ($context['string'] == 'unsubscribe' && empty($perm['unsubscribe'])) {

    // Check user's state.
    $state = og_get_entity_state($context['group']->gid, 'user', $context['account']);
    if ($state == OG_STATE_PENDING) {

      // Allow user to unsubscribe.
      $perms['unsubscribe'] = TRUE;
    }
  }
}