8

I'm using the User Points, User Karma, Vote Up/Down modules. I wonder if there is a way you can configure it to only deduct user points when you vote something down and not up.

Similar to Stack Exchange's reputation system: if you vote something up, you don't get docked, but if you vote something down you get docked reputation points.

Using the Reputation User Points -> Karma Points -> Voter Points Cost setting, I am only able to configure it to charge if you vote at all, regardless of the direction of the vote. Any ideas?

2
  • It sounds like you have to do it programatically. Check for hooks if module provide any.
    – Codium
    Jul 14, 2011 at 8:15
  • @drupality : I disagree, refer to my answer for details about why ... Jul 6, 2016 at 18:54

2 Answers 2

5

Adding a module to override User Karma's settings is certainly one option.

Another possibility is to use Rules and Voting_Rules to control your own settings for adding and subtracting user points.

Once enabled you go to /admin/config/workflow/rules and "Add New Rule". Set it up to React on Event "User votes on a Node".

Add the condition "Check the value of the vote" and if less than 0 add an Action to "Grant points to a user" but make them negative points.

Here's a screenshot of this Rule: enter image description here

Optionally, if you want to use User Karma in conjunction, you could instead React on the Event of "User was Awarded Points" and test for Conditions and override where appropriate.

1

For D7, I recommend to go for a combination of these alternative, and often used, modules to subtract (or add) user points when some node is voted down (or such downvote is removed again, which may happen too ...):

Below are the required rules, for each of these cases (use the Rules UI to import them in your own site, after you enabled the required modules mentioned above). Assumptions made in these rules:

  • They use a content type with machine name article (adapt this name to fit your own machine name, or omit that Rules Condition to enable for any content type that can be voted on).
  • The value of a downvote matches with "-1".

Downvote a node

The rule below will subtract -2 (grant -2) user points for a downvote (to the author of the node) ... AND also -1 user point for the voter:

{ "rules_votedown_node" : {
    "LABEL" : "votedown_node",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "voting_rules", "userpoints_rules" ],
    "ON" : { "voting_rules_insert_node" : [] },
    "IF" : [
      { "node_is_of_type" : {
          "node" : [ "node" ],
          "type" : { "value" : { "article" : "article" } }
        }
      },
      { "voting_rules_condition_check_vote_value" : { "vote" : [ "vote" ], "value" : "-1" } }
    ],
    "DO" : [
      { "userpoints_action_grant_points" : {
          "user" : [ "node:author" ],
          "points" : "-2",
          "tid" : "0",
          "entity" : [ "" ],
          "description" : "Receive downvote to [node:type-name] \u0022[node:title]\u0022",
          "operation" : "DownvoteReceived",
          "reference" : "By uid=[vote:uid], for [node:type-name] to q=\u003Ca href=\u0022\/node\/[node:nid]\u0022\u003E[node:title]\u003C\/a\u003E",
          "display" : "1",
          "moderate" : "default"
        }
      },
      { "userpoints_action_grant_points" : {
          "user" : [ "vote:user" ],
          "points" : "-1",
          "tid" : "0",
          "entity" : [ "" ],
          "description" : "Issue downvote to [node:type-name] \u0022[node:title]\u0022",
          "operation" : "DownvoteIssued",
          "reference" : "From uid=[node:author:uid], for [node:type-name] to q=\u003Ca href=\u0022\/node\/[node:nid]\u0022\u003E[node:title]\u003C\/a\u003E",
          "display" : "1",
          "moderate" : "default"
        }
      }
    ]
  }
}

Cancel the downvote a node

The rule below will grant +2 (= remove -2) user points for a cancelled downvote (to the author of the node) ... AND also +1 user point for the voter:

{ "rules_votedown_node_cancel" : {
    "LABEL" : "votedown_node_cancel",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "voting_rules", "userpoints_rules" ],
    "ON" : { "voting_rules_delete_node" : [] },
    "IF" : [
      { "node_is_of_type" : {
          "node" : [ "node" ],
          "type" : { "value" : { "article" : "article" } }
        }
      },
      { "voting_rules_condition_check_vote_value" : { "vote" : [ "vote" ], "value" : "-1" } }
    ],
    "DO" : [
      { "userpoints_action_grant_points" : {
          "user" : [ "node:author" ],
          "points" : "2",
          "tid" : "0",
          "entity" : [ "" ],
          "description" : "Cancel downvote to [node:type-name] \u0022[node:title]\u0022",
          "operation" : "DownvoteCancelled",
          "reference" : "By uid=[vote:uid], for [node:type-name] to q=\u003Ca href=\u0022\/node\/[node:nid]\u0022\u003E[node:title]\u003C\/a\u003E",
          "display" : "1",
          "moderate" : "default"
        }
      },
      { "userpoints_action_grant_points" : {
          "user" : [ "vote:user" ],
          "points" : "1",
          "tid" : "0",
          "entity" : [ "" ],
          "description" : "Withdraw downvote to [node:type-name] \u0022[node:title]\u0022",
          "operation" : "DownvoteWithdrawn",
          "reference" : "From uid=[node:author:uid], for [node:type-name] to q=\u003Ca href=\u0022\/node\/[node:nid]\u0022\u003E[node:title]\u003C\/a\u003E",
          "display" : "1",
          "moderate" : "default"
        }
      }
    ]
  }
}

Even though it may not be obvious from just browsing the exported rules above, note the description, operation and reference used in each of the User Point transactions.

Using such rules, the configuration of how much to charge for upvotes and/or downvotes is just a matter of adapting the values of the userpoints to be granted (or removed) using the Rules UI.

Also note the description, operation and reference used in each of the User Points transactions. That will also improve the typical User Points reports (via the various details added in the actual user point transactions).

Using the Conditional Rules module, you can consolidate these rules in a single rule also (which simplifies maintaining them).

Homework: adapt the rules shown above to implement something similar to bounties on SE (= transfer some amount of User Points from one user to another).

PS: "if you vote something down you get docked reputation points" (on SE) is only true for answers, not for questions. To refine that like you would want that to be, is just a matter of adding an appropriate extra Rules Condition (eg based on a content type of so).

3
  • Please stop writing answers that start "see my answer to this other question". If your answer to the other question solves the problem on this question, the posts will be closed as duplicates of one another. If not, then the answer is just tangential, doesn't answer the question, and needs to be deleted. I'll give you time to decide what you want to do before taking appropriate action myself. Either way, this habit of posting long answers to one question, then posting answers to several other questions that point back to it, is going to stop.
    – Clive
    Jul 6, 2016 at 13:30
  • To make it clearer: Answers that are essentially pointers to other answers given to other questions are not acceptable. Answers need to be tailored for the question being asked. If the same answer applies to two questions, chances are that a question is duplicating the other one.
    – apaderno
    Jul 6, 2016 at 18:02
  • Merci to whom just performed the equivalent of "DownvoteWithdrawn" ... Jul 6, 2016 at 21:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.