Edit Vote Count

AI-generated summary

In a discussion titled “Edit Vote Count” under the Feature category with the tag “topic-voting,” RobMeade proposes allowing admins to manually edit vote counts—such as to include external metrics like Facebook Likes—with an automated audit trail (e.g., “Rob Vote count set to 352.”) that can be edited to include context. They suggest storing such amendments under a fictitious user ID (like -2) to preserve integrity. izzy, responding a year later, confirms this is technically possible via direct database manipulation. The plugin stores vote counts in topic_custom_fields and individual votes in user_custom_fields. Simply updating the count without adjusting the user records will cause the plugin to auto-correct the count on the next vote. To avoid this, both tables must be updated: set the desired vote count in topic_custom_fields, then insert matching vote records into user_custom_fields for a chosen user ID (e.g., -2), ensuring consistency. This workaround appears to function reliably for manual vote adjustments.

On occasion, we have the need to include a total from another source, let’s say “Likes from Facebook” for a specific subject.

It would be great if it was possible to edit the current vote count. Appreciating this could look dodgy, I would expect an automated reply to be added which stated who, what and when (like that which appears when a topic is manually closed).. e.g.

“Rob Vote count set to 352.”

As an admin, I could then edit that automated reply and insert perhaps a reason, e.g. “Included likes from the Facebook post.”

I’m guessing that the votes are stored in a table somewhere against a user id also, so perhaps, a bit like the -2 user id for the discobot, a voting amendment could be stored again another fictious user?

3 Likes

I know this is a year old, but you can do this by editing the database directly.

From what I’ve found in my spelunking, the plugin keeps information about votes in 2 locations: the topic_custom_fields table contains the vote count for each topic, and the user_custom_fields table contains the actual record of each vote, tied to a user.

If you just edit the vote count in topic_custom_fields, the new vote count will display-- but the next time someone votes, the plugin will cross-check with the user_custom_fields records, realize the count is incorrect, and “fix” it back to before the edit.

So you have to also edit the user_custom_fields table so it agrees. Luckily, even though on the frontend you’re limited to 1 vote per topic per user, it looks like you can insert as many records as you want for 1 user into the database. So something like this:

UPDATE topic_custom_fields SET value = 3 WHERE name = 'vote_count' AND topic_id = <topic_id>;
 
INSERT INTO user_custom_fields VALUES ( DEFAULT,<user_id>,'votes',<topic_id>,<timestamp>,<timestamp>);
INSERT INTO user_custom_fields VALUES ( DEFAULT,<user_id>,'votes',<topic_id>,<timestamp>,<timestamp>);
INSERT INTO user_custom_fields VALUES ( DEFAULT,<user_id>,'votes',<topic_id>,<timestamp>,<timestamp>);

That way, assuming the vote_count was 0 at first, you’ve set it to 3 and given it 3 records to chew on when it goes to cross-check that number. Seems to work o-k for me, and you should be able to set the user_id to -2 or whatever you want.