2

In using the rule OG new content notification (admin/config/workflow/rules/reaction/manage/rules_og_new_content) for a site using Organic groups. However, I'd like add in the name (and URL) of the parent group. However, I'm not seeing these options in the tokens ("replacement values").

The Content Type in question has the field og_group_ref for which I'm trying to target.

enter image description here

What I've tried so far (update):

On a dev instance, as per Pierre's recommendation below, I've added the following 'fetch entity' to the rule.

enter image description here enter image description here

But the email comes in blank, without title on the subject line enter image description here

  • 1
    The best way to accomplish this is to create a custom token. In function myhook_myfunction() you can query the database and node_load the node group you like, otherwise you have, somehow, to pass the node id (nid) through Rules. I hope it helps. – mchar Dec 28 '15 at 22:04
  • @mchar The above is more of an answer candidate than a comment. Move it below. I'd be willing to try if you expand it out into an answer. Either way. Comment upvote. – Rick Dec 30 '15 at 16:52
4
+50

Add Action >> Get group members from group audience >> node

Add Loop >> node:og-group-ref

  • Add Loop inside loop >> group-members >> rename list_item to list_item2

    • Add Action >> Fetch entity by property >> User >> Mail >> list-item2:mail
    • Add Action >> Fetch entity by property >> OG Memembership >> field_name >> list-item:title >> rename entity_fetched to entity_fetched2
    • Add Action >> Send Mail >> list-item2:mail >> list-item:title

End Result:

enter image description here

(click image to enlarge)

  • Definitely an upvote. I've added more to my question. I'm not yet getting the value of the title. Did I miss anything? This approach seems to be the more manageable in the long run. So getting this to work would be great. – Rick Dec 30 '15 at 16:51
  • Looks like we made a bit of progress. But from what I can see now near the top of the rules Action screen you added, I wonder why you added the "-0" part in the identifier for your "Fetch entity by id". Can you try without that "-0" to see what result you get? Also, what is that "Send mail" within your loop (is that a "rules component")? And can you also explain a bit the screenprint wiith "subject", etc? – Pierre.Vriens Dec 30 '15 at 21:33
  • The offset appears to be a required field. The send mail was in the existing rule (from og_exrtas?). It send s an email to each group member. – Rick Jan 2 '16 at 19:19
  • Bounty awarded b/c it's about to expire. Though any additional thoughts are welcomed. – Rick Jan 4 '16 at 19:42
  • @rgchi did you try the revised answer? – No Sssweat Jan 5 '16 at 1:47
1

The accepted answer didn't work for me. This is the configuration I ended up using to get the group name in the email.

enter image description here

0

to insert the name of group in the mail, you need to use [node:og-group-ref] replacement token.

  • what if he was referencing multiple OG groups? I am afraid this will print the other groups name as well. – No Sssweat Jan 4 '16 at 10:48
  • Yes, it will add both group name, if it will be not an issue then @rgchi can use this token. – Dev Jan 4 '16 at 11:32

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.