Overriding OG Entity Label

Public

Override an entity label in OG. This is usually the bit that says "username in group group name".

Get raw version
php
  1. function modulename_entity_info_alter(&$entity_info) {
  2. // Alter the og membership label callback to be our own funciton
  3. $entity_info['og_membership']['label callback'] = 'modulename_og_membership_label';
  4. }
  5.  
  6. /**
  7.  * Rewrite of the og_membership_label() function to produce better output for our purposes.
  8.  */
  9. function modulename_og_membership_label($og_membership) {
  10. $wrapper = entity_metadata_wrapper('og_membership', $og_membership);
  11. $params = array(
  12. '@entity' => $wrapper->entity->label()
  13. );
  14. return t('@entity', $params);
  15. }