og_is_group_member

Versions
6
og_is_group_member($gid, $include_admins = TRUE, $uid = NULL)

Check a user's membership in a group.

Parameters

gid An integer or a node object representing the group node.

$include_admins Whether or not site admins are considered members.

$uid Pass a user id, or pass NULL in order to check current user.

▾ 10 functions call og_is_group_member()

file_og_browser_access in contributions/fileframework/file.module
Check groups browser access.
file_og_gallery_access in contributions/fileframework/file.module
Check groups gallery access.
meetings_attendance_access in contributions/meetings/meetings.module
Check if the user is allowed to take or view attendance.
og_approve in contributions/og/og.module
og_block_details in contributions/og/og.module
og_home_empty in contributions/og/og.module
og_menu_access_invite in contributions/og/og.module
og_menu_access_picture in contributions/og/modules/og_views/og_views.module
og_menu_access_unsubscribe in contributions/og/og.module
Check if current user may unsubscribe the specified user from the specified group.
og_rules_action_subscribe_user in contributions/og/includes/og.rules.inc
Action: Subscribe user to group.

Code

contributions/og/og.module, line 270

<?php
function og_is_group_member($gid, $include_admins = TRUE, $uid = NULL) {
  if ($uid) {
    $user = user_load(array('uid' => $uid));  
  }
  else {
    global $user;
    // Adventurous modules can cause us to arrive here before og_init() has fired.
    // See http://drupal.org/node/285696
    if (!isset($user->og_groups)) {
      $user = user_load(array('uid' => $user->uid));  
    }
  }

  // Allow caller to pass in a full $node. Used by menu items.
  if (is_object($gid)) {
    $gid = $gid->nid;
  }
  
  $groups = array_keys($user->og_groups);
  if ($include_admins) {
    return user_access('administer nodes', $user) || in_array($gid, $groups) ? TRUE : FALSE;
  }
  else {
    return in_array($gid, $groups);
  }
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.