Rules won't subscribe users

tororebelde - May 15, 2009 - 12:59
Project:Organic groups
Version:6.x-2.x-dev
Component:og.module
Category:bug report
Priority:normal
Assigned:Unassigned
Status:duplicate
Description

Hi,

I have a triggered rule to give a user a role and to automatically subscribe to a group. To this I used "Subscribe user to group" OG action, but it doesn't work.

After looking a bit at code, I found a missing param on og_is_group_member function, at og.rules.inc. Now it works fine.

This is the change I've made:

function og_rules_action_subscribe_user($user, $node, $settings) {
  if (!og_is_group_member($node->nid, FALSE, $user)) {
    og_save_subscription($node->nid, $user->uid, array('is_active' => (int)$settings['is_active']));
  }
}

at line 126 on og.rules.inc.

I supposed to use FALSE, because the user may not be admin.

Thanks.

#1

NynjaWitay - August 20, 2009 - 21:37

In order for me to get the rule working, I had to make one additional adjustment. og_is_group_member takes the uid, not the user as its third parameter.

function og_rules_action_subscribe_user($user, $node, $settings) {
  if (!og_is_group_member($node->nid, FALSE, $user->uid)) {
    og_save_subscription($node->nid, $user->uid, array('is_active' => (int)$settings['is_active']));
  }
}

#2

Theiss - August 20, 2009 - 22:10

I don't think you know what you're talking about Nyn. You might be new to Drupal or something. The og_is_group_member does take the uid as the third parameter though. I would recommend reading http://drupal.org/handbook/modules/og before trying to use the module to its fullest capabilities. Also, it is very well documented, as it is going to be a Core module in Drupal 7.

#3

NynjaWitay - August 21, 2009 - 22:13

There definitely needs to be some boolean for the second parameter. The default is TRUE, and the variable is called "include_admins." It's description reads "Whether or not site admins are considered members." Looking at it now, I'm not sure what the value should be in this fix.

Documentation has nothing to do with finding bugs that make this rule nonfunctional. Looking through the code is the only way.

OG isn't going to be core, either. From the first line of the main OG page: "#D7CX: I pledge that Organic Groups will have a full Drupal 7 release on the day that Drupal 7 is released."

#4

droidenator - November 6, 2009 - 23:14

For whatever it's worth, I used the changes that NynjaWitay suggested and they work fine.

#5

crea - November 25, 2009 - 04:14
Status:active» duplicate

This issue is older, but I already posted patch at #620032: Rules integration calls og_is_group_member() with wrong arguments. so setting this as dupe.

 
 

Drupal is a registered trademark of Dries Buytaert.