Can anyone assist with a PHP snippet to generate a list of a user's subscribed (O.G.) groups?

This is available on the user profile, but I would like to add them to the side navigation of my site.

Thanks!!

Comments

nevets’s picture

The following snippet when place in a PHP block will list the users OG groups. If the user is not logged in or does not belong to any groups no output is produced (and the block disappears)

<?php
global $user;

if ( $user->uid ) {
  if ($user->og_groups) {
    foreach ($user->og_groups as $key => $val) {
      $links[] = l($val['title'], "node/$key");
    }
    $output = theme('item_list', $links);
  }
}

print $output;
?>
bernie’s picture

Thank you nevets! Just what I needed!

michellezeedru’s picture

Hi - new to Drupal and using snippets, but I think this will be really helpful for me, too. But I have a view that lists members and various data in their profiles. I'd also like to include a list of the users OG groups. I don't see how I can incorporate a snippet like this in the view. Can someone help?

Using Drupal 6.4 and Views2.

Thanks!