1

I created a Rule that grants Userpoints to users when they comment on a node. However, I would like to grant these points only once per node per user. That means future comments from the same user on that node should not result in extra points.

How can I do that?

  • Can you access number of comment by that user on a given node? If so, rule should fire on comment add, but with condition like comments by user == - and second rule should remove these points on comment deletion. But that's just a rough idea, nothing solid yet. – Mołot Oct 11 '13 at 11:23
  • I like your idea, but I don't know how I can access the number of posted comments. If I could and if I could use it with Rules as you said, I think my problem is solved. – Jeroen Oct 11 '13 at 13:21
1

I solved my problem with the Flags module: I created the flags called 'Commented on this node' & 'First reaction'* and rule called 'Commented on a node'. These are my rule's settings:

EVENTS: After saving a new comment

CONDITIONS:

  • Content is of type Parameter: Content: [comment:node], Content types: Article
  • NOT Node is flagged Parameter: Flag: Commented on this node, node: [comment:node], User on whose behalf to check: [comment:author]

ACTIONS:

  • Grant points to a user Parameter: User: [comment:author], Points: 2, Points category: Reaction, Entity: [comment:node], Description: New reaction, Operation: Add, Display: false, Moderate: Automatically approved
  • Flag a Node Parameter: Flag: Commented on a node, Node: [comment:node], User on whose behalf to flag: [comment:author], Skip permission check: false
  • Flag a Comment: Parameter: Flag: First reaction, Comment: [comment], User on whose behalf to flag: [comment:author], Skip permission check: false

So, every time a user adds a comment to a certain node for the first time, the node is flagged as 'Commented on a node', the reaction is flagged as 'First reaction' and the user who added the comment is rewarded 2 points.

**I use the 'First comment' flag in a related question.*

-1

I would create a new role and use rule module to grant points. Point will be granted only (along with the role) if the user doesnt have the role assigned to him already.

  • 1
    So that means a user gets a new role every time he/she comments for the first time?! That doesn't sound very realistic/practical to me to be honest... – Jeroen Oct 10 '13 at 21:51
  • well, i just proposed a solution :-) ; another solution would be create a point category "comment points" and using hook_rules_condition_info create a new condition (smthing like "user was already granted comment points") (will look up current user and the new points category) this solution is actually better if you decide to use expiration for points. might not be that performant tho – Victor Oct 10 '13 at 22:05
  • 1
    I actually already have such a category. But I think you misunderstood my question. The user shouldn't be awarded more points when he/she reacts on the SAME node, but he/she will be granted points nevertheless after commenting on ANOTHER node. See why your solutions won't make much sense in this situation? :) – Jeroen Oct 10 '13 at 22:15
  • I now see why you proposed those solutions. They would actually be perfect in the way you interpreted my question. I didn't expect my question to be ambigue and I clarified it. I'm sorry for my (rather shocked) reaction. – Jeroen Oct 10 '13 at 22:29

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.