It would be useful to have an Entity API metadata property that returns the OG roles for a membership entity.

This would be analogous to the 'roles' property that Entity API provides on users. However, in the OG case the only entity where it makes sense to place the property is the OG membership, as that has a connection to both the user and the group. If you have just a user, you can't tell the metadata wrapper which group you are interested in.

OG membership entities also represent relationships between a group and its actual content (such as nodes): in this case, this roles property would return an empty array.

Patch coming!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim’s picture

amitaibu’s picture

Status: Active » Needs review
amitaibu’s picture

What's the use case of using it. Why not just call og_get_user_roles() directly -- Is it for Rules?

joachim’s picture

It's actually for a reports & statistics system I am building, where it make life a lot easier if I access every piece of data about entities via the metadata wrapper.

But I suppose you could also use it for Rules.

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

+1 on this. I really need role information exposed to Rules. Besides, is there any good reason to NOT expose this information to Entity API? @joachim's patch works for me!