Is there a small php snippet to return true/false for whether a user is a group admin (not just the owner, which is easy)?

Thanks

Comments

pbarnett’s picture

<?php
global $user;
$nid = 1240; // gid of the group
$is_admin = db_result(db_query('SELECT is_admin FROM og_uid WHERE uid = %d AND nid = %d', $user->uid, $nid));
print "User $user->uid is_admin for group with gid $nid: $is_admin";
?>
oschirok’s picture

I prefer using the build in function
og_is_node_admin($node)

moshe weitzman’s picture

Status: Active » Fixed
scedwar’s picture

I ended up with this:


//check og module exists
if (module_exists('og')){

//check we've got a group, rights to view the group, 
// and of type "group_type" - change this to whichever group you want to restrict the block to
//or remove the condition entirely

if (($group = og_get_group_context()) && node_access('view', $group) && ($group->type == 'group_type') ) {

 //check current user is a team admin
 if (og_is_node_admin($group))  return TRUE;

 }
}
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

am22’s picture

In OG 6 the function is called og_is_group_admin($group);