function og_ui_og_user_access_alter in Organic groups 7.2
Same name and namespace in other branches
- 7 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 851 - Organic groups UI.
Code
function og_ui_og_user_access_alter(&$perms, $context) {
if ($context['string'] != 'unsubscribe' || !empty($perm['unsubscribe'])) {
return;
}
$group_type = $context['group_type'];
$group = $context['group'];
list($id) = entity_extract_ids($group_type, $group);
$og_membership = og_get_membership($group_type, $id, 'user', $context['account']->uid);
if (empty($og_membership) || $og_membership->state != OG_STATE_PENDING) {
return;
}
// Allow user to unsubscribe.
$perms['unsubscribe'] = TRUE;
}