Hi

I've setup a rule that logs which user flagged another user.
I have one user flag and I want that each time a user flag another one, it is shown something like !username flagged !user.

Hower, when i setup my rule, I get the message Property name flagged property name.
I've also setup an action to display a message on the website, and that message has the correct name written but not in heartbeat.

What did i do wrong?

Thanks

Comments

Stalski’s picture

Status: Active » Closed (cannot reproduce)

This is the code that works for me. This is tested with dev (not 7.x-1.0).
This is code that also works with latest dev, cannot be imported without upgradng to dev version.
The code for heartbeat template:


/**
 * Implements hook_ctools_plugin_api().
 */
function _ctools_plugin_api($module, $api) {
  if ($module == 'heartbeat' && $api == 'heartbeat') {
    return array('version' => 1);
  }
}

/**
 * Implements hook_heartbeat_template_info().
 */
function example_heartbeat_template_info() {
  $heartbeatmessagetemplates = array();

  $heartbeatmessagetemplate = new HeartbeatMessageTemplate();
  $heartbeatmessagetemplate->disabled = FALSE; /* Edit this to true to make a default heartbeatmessagetemplate disabled initially */
  $heartbeatmessagetemplate->api_version = 1;
  $heartbeatmessagetemplate->message_id = 'user_like';
  $heartbeatmessagetemplate->description = 'Like another user';
  $heartbeatmessagetemplate->message = '!username likes !user';
  $heartbeatmessagetemplate->message_concat = '';
  $heartbeatmessagetemplate->perms = 4;
  $heartbeatmessagetemplate->group_type = 'single';
  $heartbeatmessagetemplate->concat_args = array(
    'group_by' => 'none',
    'group_target' => '',
    'group_by_target' => '',
    'group_num_max' => '',
    'merge_separator' => '',
    'merge_end_separator' => '',
    'roles' => array(
      1 => 0,
      2 => 0,
      3 => 0,
      4 => 0,
      5 => 0,
    ),
  );
  $heartbeatmessagetemplate->variables = array(
    '!username' => '',
    '!user' => '',
  );
  $heartbeatmessagetemplate->attachments = array(
    'buttons' => array(
      'weight' => array(
        'flagattachment:like' => '0',
        'activitycomments' => '2',
      ),
      'settings' => array(
        'activitycomments' => array(
          'activitycomments_node' => 0,
        ),
      ),
      'enabled' => array(
        'flagattachment:like' => 'flagattachment:like',
        'activitycomments' => 0,
      ),
    ),
    'content' => array(
      'weight' => array(
        'flagattachment:like' => '0',
        'activitycomments' => '2',
      ),
      'enabled' => array(
        'flagattachment:like' => 'flagattachment:like',
        'activitycomments' => 0,
      ),
    ),
  );
  $heartbeatmessagetemplates['user_like'] = $heartbeatmessagetemplate;

  return $heartbeatmessagetemplates;
}

The code for the rule of the user like thing:

{ "rules_user_like" : {
    "LABEL" : "user_like",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "heartbeat_rules", "flag" ],
    "ON" : [ "flag_flagged_user_like" ],
    "DO" : [
      { "heartbeat_activity_user_like" : {
          "nid" : "0",
          "uid" : "[flagging-user:uid]",
          "nid_target" : "0",
          "uid_target" : "[flagged-user:uid]",
          "cid" : "0",
          "message_id" : { "value" : { "user_like" : "user_like" } },
          "!username" : "[flagging-user:name]",
          "!user" : "[flagged-user:name]"
        }
      }
    ]
  }
}

It seems to me it works as designed.

warmth’s picture

I wanna do the same but when a Heatbeat activity is flagged under "I like", can you please help me?

jdleonard’s picture