Community Documentation

OG User Roles: Hooks

Last updated March 7, 2009. Created by SomebodySysop on September 18, 2007.
Log in to edit this page.

    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

    <?php
    /**
    * 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

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 5.x, Drupal 6.x
Audience
Site administrators

Site Building Guide

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.
nobody click here