2

I want to extend the entity properties of OG-Membership to use it as a token in rules.

It works fine adding the property (for example the string 'test' as returned in the getter_callback is printed in a reaction rule (sending email)). But I could not find out, or how to debug/access, the other properties present in OG-Membership in the rules context. To put it differently:

How can I access the group id ($gid) of the OG-Membership in my getter callback?

This works well:

function mymodule_entity_property_info_alter(&$info){
  $properties = &$info['og_membership']['properties'];

  $properties['og_custom_property'] = array(
    'label' => t('My custom Label'),
    'type' => 'test',
    'description' => t('OG Membership Custom Property.'),
    'getter callback' => 'mymodule_callback'
    );
  return $info;
}

But here I cannot access the $gid, or anything, for that matter:

function mymodule_callback(){
  //do some stuff with the $gid and $etid of the OG-Membership
}

Any help is appreciated; maybe someone knows how to debug the in rules available properties? Thanks.

2

If you use hook_entity_property_info_alter() you have access to the entity in question in the callback as well.

function mymodule_callback($item){
  //$item is the entity in question in my case $og_membership
  //hence I can acces the gid like this:
  $og_membership = $item; //redundant, just to show what I mean
  $gid = $og_membership->gid;

  //either do some more stuff or just return the gid as an example
  return $gid;
}

Now I can access the property and it returns the gid. For example in rules:

[og_membership:og_custom_property]

Hope this is useful to others as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.