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?
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:
Add new field - Global: PHP (you have to enable Views PHP module for this field) and put below code in this field:
<?php
global $user;
$account = user_load($user->uid);
$ugrpid = $account->og_user_node['und'][0]['target_id'];
if($row->gid == $ugrpid){
echo "Already Subscribed.";
}else{
echo "Not member of this Group.";
}
?>
This is how my view look like( Screenshot ).