Hi,

I could not find the option to send the membership request message to the users whose role is "administrator" in the group,
the token would be like [og:role:administrator:mail], is this a present available option?

So far one can only send this message to the group author (which means the groupp manager, in case someone is looking for this).
But if you want more than one person to administrate the group, you cannot send the message to the admin members, so if one is in vacation, he has to inform the site admin so that I have to change the group owner.

Thanks

CommentFileSizeAuthor
#11 rules.pdf113.35 KBphillipclarke29
#5 settings.png30.79 KBSinan Erdem
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drupalycious’s picture

I see in rules that there is the option "send email to all users of a role" but it refers to the global roles of the drupal site not og.
It would be nice to have the option "send email to all users of a role in a group".

Thanks

andrewoke’s picture

I just had this exact same problem. It would be nice to see in rules, but if you're stuck you can do this:

In actions, get group members from group audience, add a loop, and than in the loop add custom php code:

$og_roles = og_get_user_roles($node->group_audience['und'][0]['gid'], $list_item->uid, true);

if($og_roles) {
  $og_role_names = og_get_user_roles_name($og_roles);
}

if(in_array('Publisher', $og_role_names)) {
// or send an email
drupal_set_message("message going to be sent to user $list_item->name");
}
m.zerres’s picture

I'm looking for that, too. Did you get it to work with actions? I can't see any option "get group members from group audience".

Sinan Erdem’s picture

@andrewoke,

How can I use tokens or data selectors inside this code? For example I want to send an email whose body is containing the title and the author of a newly created node.

Sinan Erdem’s picture

FileSize
30.79 KB

When I use the code on comment #2 in a php code action under a loop, I get this message when I save a node:

Fatal error: Class name must be a valid object or a string in /home/administrator/metalface/includes/common.inc on line 7656

Attached is my rule configuration.

andrewoke’s picture

I'm going to assume it's because you haven't changed this line:

if(in_array('Publisher', $og_role_names)) {

Change 'Publisher' to an og role that exists.

andrewoke’s picture

@sinanerdem - If you check out the php variables available in the action you should have access to $node so you can do something like:

if(in_array('My Role', $og_role_names)) {
$body = $node->body
$loaded_user = user_load($node->uid);
$mail = $loaded_user->mail;

//send_drupal_message (look up a mail wrapper function since it takes a bit of code to send an email in D7
}
Sinan Erdem’s picture

Thanks for the answer. I will try it as soon as possible.

Premier Andrew’s picture

How would I go about doing this by selecting the group to notify from the groups_audience (og_group_ref) field attached to the user?

korzh-nick’s picture

The issue date. Does it have a solution?

phillipclarke29’s picture

FileSize
113.35 KB

I am trying to send a message to members of an OG with the role Foster Carer when an OG node's workflow has moved from one status to another - I have fiddled for a while with no luck. My custom php is

$og_roles = og_get_user_roles($node->group_audience['und'][0]['gid'], $list_item->uid, true);

if($og_roles) {
$og_role_names = og_get_user_roles_name($og_roles);
}

if(in_array('Foster Carer', $og_role_names)) {
// or send an email
drupal_set_message("message going to be sent to user $list_item->name");
}

I have attached the rule screen grab below. I just get a blank screen and no email - any ideas? Thanks

phillipclarke29’s picture

Issue summary: View changes

some mistakes in the text

sgoelz’s picture

Had the same issue as described in #7 and #11

For me worked this code:

$og_role_id=6; // The id of your desired og_role
$og_roles = og_get_user_roles('node', $node->group_audience['und'][0]['gid'], $list_item->uid, true);

if(isset($og_roles[$og_role_id])) {
  // or send an email
  drupal_set_message("message going to be sent to user $list_item->name");
}

You need to specify the entity type of the group in og_get_user_roles().

In addition i replaced checking the role name by checking the role id.

SurendraYellu’s picture

Issue summary: View changes

Hi, i am trying to use this solution for the flagged nodes.
Suppose, if a user flags a content in a group, the mail should go to the users of a particular role in the group. So, i changed the code in #2 as follows;

$node=node_load($flagged_node->id);
$og_roles = og_get_user_roles('node',$node->group_audience['und'][0]['gid'], $list_item->uid, true);
if($og_roles) {
  $og_role_names = og_get_user_roles_name($og_roles);
}
if(in_array('administrator member', $og_role_names)) {
drupal_set_message("message going to be sent to user $list_item->name",'status');
}

But, this is not working. How can i refer the flagged node in PHP?