OG User Roles: Hooks

Last updated on
30 April 2025

You are browsing documentation for an older version of Drupal, which is not supported any longer, and the information may not be correct. See current documentation for Contributed modules

    hook_og_user_roles_gid

    As of release 5.x-2.5.
    Description
    Hook to allow other modules to supply a Group Node ID to identify the group a user is in.
    Parameters
    No input parameters.
    Return value
    Returns a single Group Node ID which should be defined by your module as the current group context for the current user.
    Sample code

/**
 * implementation of hook_og_user_roles_gid();
 *
 * @param No input parameters
 * @return $gid numeric value containing the current group node ID
 */
function filenode_og_user_roles_gid() {
  if (arg(0) == 'og' && arg(1) == 'files') {
    if (is_numeric(arg(2))) {
      $gid = arg(2);
    } elseif (is_numeric(arg(3))) { // E.g. og/files/create-subdir/104
      $gid = arg(3);
    }
  }
  if ($gid) return $gid;
}

Reference
http://drupal.org/node/176390

Help improve this page

Page status: Not set

You can: