Sometimes known as "karma". In our case, we wanted storylink submitters to get more/less userpoints when someone up/down votes their submissions.
Described in this feature request for 4.7: http://drupal.org/node/101791
The attached patch adds to two functions:
1. vote_up_down_userpoints()
Adds an additional field at admin/settings/userpoints in the vote_up_down fieldset:
$form['vote_updown_points']['userpoints_vote_up_down_karma'] = array(
'#type' => 'textfield',
'#title' => t('Points resulting from vote on a node user authored (requires the Vote up/down module)'),
'#default_value' => variable_get('userpoints_vote_up_down_karma', 0),
'#size' => 5,
'#maxlength' => 5,
);
2. vote_up_down_vote()
In the userpoints integration section... after giving the voter a userpoint, give the author a userpoint.
// update userpoints based on the vote value
if ($vote->value != 0) {
if ( variable_get('userpoints_vote_up_down_karma', 0) ) {
userpoints_userpointsapi('points', ($vote->value * variable_get('userpoints_vote_up_down_karma', 0)), $node->uid, 'Vote up/down karma');
}
}
Comments
Comment #1
ola90@drupal.ru commentedHow does this code handle the case when a user first votes "up" and then changes his mind and votes "down"? It looks like author's karma will be reset to 0 while his node will have a negative score.
Comment #2
Greg Go commentedola90, you're absolutely right. Thanks!
I took your code from http://drupal.org/node/101791, added configurable userpoints multipler and rolled another patch.
Comment #3
Anonymous (not verified) commentedOMG, thanks so much for fixing that - was trying to figure this one out but it was making my brain hurt!
fyi - if you enable 'reset vote' it doesn't reset the points, but in my case I'm not going to enable that, just thought you might like to know...
Comment #4
Anonymous (not verified) commentedJust been wrapping my head around why this wasn't working as I had it working fine before - it's because the userpoints api has changed so now you need to pass an array of values:
http://drupal.org/node/206558
e.g.
$params = array (
'uid' => $node->uid,
'points' => ($vote->value * variable_get('userpoints_vote_up_down_content_rating', 0)),
'description' => 'Vote up/down karma',
);
userpoints_userpointsapi($params);
instead of:
userpoints_userpointsapi('points', ($vote->value * variable_get('userpoints_vote_up_down_content_rating', 0)), $node->uid, 'Vote up/down karma');
...so in other words, these patches don't work at the moment with the latest userpoints
Comment #5
chadchandler commentedAny updates on this?
Comment #6
Gekiboy commentedThis, and other code in this module around the userpoints system is broken. As this module uses the votingapi module, all userpoint functionality base on voting should be taken care of by the userpoints_votingapi anyway. I am proposing this patch to remove the traces of userpoints functionality from this module as it is only detrimental at this point.
Comment #7
Gekiboy commentedRecreated the patch using CVS instead of SVN incase that matters
Comment #8
mrwhizkid commentedI am trying to follow this thread and I am confused. Is there a way in Drupal 6 to give points to the author when his/her node is voted up? Or the other way around?
Comment #9
ingo86 commentedThis thing is absolutely out of the range of features of vote up down.
This is just a voting module that interfaces with voting_api. Nothing else.
For what you need, I developed as part of this year google Summer of Code a set of modules that do just what you require. Everything is interfaced with user_karma. If you wanna taka a look go here:
http://drupal.org/project/peerreview
Everything needs work but the code should be good, for your needs you have to enable the user_karma plugin.
Comment #10
ingo86 commentedComment #11
DomDoze commentedSubscribe to read later