Getting og membership type in template.tpl.php I want to obtain the organic groups role-id of a node/comment-author in node.tpl.php and comment.tpl.php. 

I can't find an array that provides this information.

I want to add a class based on the authors membership type.

Dummycode:

&lt;div id="header" class="&lt;?php if ($author-&gt;rid == 7): print 'class-7'; endif; ?&gt;"&gt;


How to do this for nodes and comments?

Note: for normal (non-organic-group) roles I use:

&lt;?php if(in_array('administrator', $user-&gt;roles)): print 'admin-type'; endif; ?&gt;


Which works ok, I want similar usage for organic group roles.
Found the anwser:
This goes in node.tpl.php (tested on Drupal 7, Organic groups 7.x-2.3)

&lt;?php if (og_context()) {
  $group = og_context();
  $userid = user_load($node-&gt;uid);
  $roles = og_get_user_roles('node', $group[gid], $uid = $userid-&gt;uid, $include = FALSE);
  }
?&gt;


Then use it with something like: 

&lt;?php if(in_array('test member', $roles)): print '&lt;span&gt;Testuser&lt;/span&gt;'; endif; ?&gt;


For comments it's a little different:

&lt;?php if (og_context()) {
  $group = og_context();
  $roles = og_get_user_roles('node', $group[gid], $uid = $comment-&gt;uid, $include = FALSE);
  }
?&gt;


Works only on pages where groupcontext is available!