Hello

I have a pretty straightforward question which so far I've not been able to find a straightforward answer to:

I just need to be able to detect when a user subscribes to an organic group so that I can fire some code on that event*. It looks like the module exposes something to other modules in og_save_subscription (line 714 in og.module):

module_invoke_all('og', 'user update', $gid, $uid, $args);

but I have no idea what that means, and none of my attempts to hook into the event in my custom module have been successful so far (e.g. mymodule_og(..))

*There is an issue with the rules module that prevents me doing this with rules (http://drupal.org/node/1232404)

Comments

Anonymous’s picture

Apologies if you've already tried this but a quick peek at the code for module_invoke_all would suggest something like this will work:

function mymodule_og($op, $gid, $uid, $args) {
  if ($op == 'user update') {
    drupal_set_message("GroupID: $gid, UserID: $uid");
  }
}

Hope that helps

andystox’s picture

Thanks for the answer but unfortunately I've tried that already. I thought it might be something to do with the relative module weights so I've tried changing them without any luck, nothing I put in the hook ever seems to fire (I'm just testing it by trying to write a message to the log).

andystox’s picture

Apologies, this does work, I was being an idiot, I changed the module name when testing the weights and forgot to change it back.