MyBB Community Forums

Full Version: Poll votes based on user-reputation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
When a user votes in a poll, the weight/importance of their vote is based on their reputation:

In [polls.php] change the following code:

$votesarray[$voteoption-1]++;
//$votepower = $mybb->user['reputation'];
//$votesarray[$voteoption-1] = $votesarray[$voteoption-1] + $votepower;

$votesarray[$option-1]++;
//$votepower = $mybb->user['reputation'];
//$votesarray[$option-1] = $votesarray[$option-1] + $votepower;

--$votesarray[$vote-1];
//$votepower = $mybb->user['reputation'];
//$votesarray[$vote-1] = $votesarray[$vote-1] - $votepower;

--$votesarray[$voteoption-1];
//$votepower = $mybb->user['reputation'];
//$votesarray[$voteoption-1] = $votesarray[$voteoption-1] - $votepower;

To make the change, find the uncommented part in the file, comment it out, and underneath it add the two lines, and uncomment those

And to let them undo their votes (so that the second half of the above changes have any effect):
AdminCP -> "Users & Groups" -> "Groups" -> (pick a group) "Options" -> "Edit Group" -> "Forums and Posts" -> "Can undo votes in polls?"

I'm going to do something where:

the top 25% reputation users have $votepower of 5
the middle 50% reputation users have a $votepower of 3
the bottom 25% reputation users have a $votepower of 1
and negative reputation users (not sure if this is a thing?) have a $votepower of 0

Not sure how I'm going to calculate those percentages yet though

When you open a thread, it'll show the wrong # of votes after the above change

To fix it, go to ~line 608 in [showthread.php], find the comment "// Decide what poll status to show depending on the status of the poll and whether or not the user voted already."

And insert this code right above that comment:

$query = $db->simple_select("polls", "numvotes", "tid='".$tid."'");
$thispollqueryresult = $db->fetch_array($queryy);
$totalvotes = $thispollqueryresult['numvotes'];
need more details about it...
Thx for this tutorial..
Its possible to change it like when users have votepower base not on reputation, but for example on their share in organization? For example user A has share like 3150/1502880, user B has share 5500/1502880 etc..
How do you get the share?
(2020-12-03, 08:30 PM)OmarĀ G. Wrote: [ -> ]How do you get the share?
For start will be inserted manually.. Share values are known numbers..
Where are they stored tho? You use a profile field?
Yeah, i suppose that it will be in some profile field..
There could be an option that it may not be share i wrote above, but vote weight could be in percent.. those fractions can be converted to percentages if that would help .. so then user A has vote with weight 1,5%, user B has vote with weight 0,7% ..