# Edit Vote Count

**URL:** https://meta.discourse.org/t/edit-vote-count/78767
**Category:** Feature
**Tags:** topic-voting
**Created:** [January 23, 2018, 3:54pm UTC](https://meta.discourse.org/t/edit-vote-count/78767 "2018-01-23T15:54:10Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![RobMeade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/robmeade/32/109119_2.png) [@RobMeade](https://meta.discourse.org/u/RobMeade)
#### Post date: [January 23, 2018, 3:54pm UTC](https://meta.discourse.org/t/edit-vote-count/78767/1 "2018-01-23T15:54:10Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![izzy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/izzy/32/156031_2.png) [@izzy](https://meta.discourse.org/u/izzy)
#### Post date: [January 3, 2019, 9:12pm UTC](https://meta.discourse.org/t/edit-vote-count/78767/2 "2019-01-03T21:12:59Z")

</div>

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:

```plaintext
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.
