Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It seems there isn't a default rule for user relationships out of the box, here's a basic one I've created which others might find useful:
{ "rules_log_activity_when_user_relationship_is_made" : {
"LABEL" : "Log activity when user relationship is made",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "heartbeat_rules", "user_relationships_rules" ],
"ON" : [ "user_relationships_approve" ],
"DO" : [
{ "heartbeat_activity_heartbeat_become_friends" : {
"nid" : "0",
"uid" : "[requester:uid]",
"nid_target" : "0",
"uid_target" : "[requestee:uid]",
"message_id" : { "value" : { "heartbeat_become_friends" : "heartbeat_become_friends" } },
"!username" : "[requester:link]",
"!user2" : "[requestee:link]"
}
}
]
}
}
Would this be useful to include in the default rules? Maybe this rule could be included but set to disabled by default (this issue may be relevant when thinking about this: http://drupal.org/node/1471566 )? I'll create a patch if others agree.
Comments
Comment #1
hedley CreditAttribution: hedley commentedHere's another rule I've created. The one above saves one activity status in the database (User A is now friends with User B), the one below saves two (User A is now friends with User B + User B is now friends with User A) saving two activity statuses allows each to be associated with a different UID, for my purposes I'm using views to display heartbeat activity and this method works well.
Comment #2
dieppon CreditAttribution: dieppon commentedHi,
I have a simple mutual relationship call "friend" and would like to show the users that 2 specific users has become friends, which rule should I add?
Thanks
Comment #3
hedley CreditAttribution: hedley commentedThe first rule I posted should be sufficient but they will both do the job in different ways. Logging one status update (the first method) will cause comments posted on the status on either users stream to be visible on both, logging two status updates (the second method) will keep comments separate.
Comment #4
Stalski CreditAttribution: Stalski commentedThis is certainly something that can go into the defaults of heartbeat, it was for drupal6. On the time of writing the biggest part, rules integration was not yet done if I recollect correctly.
I'll test the code and push it to git ;) Thx.
Comment #5
Stalski CreditAttribution: Stalski commentedAdded to git. Can somebody test this out to make sure?
Comment #6
Stalski CreditAttribution: Stalski commentedReopen if this is not working.