Field for if the current user is a member of the organic group I am working with Services module to create an API. I have created a View that shows list of Organic groups.

Now I need to add a field which will show if the current user is member of the group or not. Can anyone please tell me how to do this?
There is no field or direct method to show "If the current user is member of the group or not". In your case I have found a solution here:


Create a view - showing list of all groups(you have already created).
Add new Relationship - OG membership: OG membership from Node group
Add new field - (OG membership from node group) OG membership: Group ID (Group ID), you can exclude it from display.
Add new field - Global: PHP (you have to enable Views PHP module for this field) and put below code in this field:

&lt;?php

global $user;
$account = user_load($user-&gt;uid);
$ugrpid = $account-&gt;og_user_node['und'][0]['target_id'];

if($row-&gt;gid == $ugrpid){
  echo "Already Subscribed.";
}else{
  echo "Not member of this Group.";
}

?&gt;



This is how my view look like( Screenshot ).