Jump to content

Question implementing poll (limiting number of votes by each IP address?)


shawnadelic
 Share

Recommended Posts

Hi, I'm working on implementing a poll system with a variable number of choices that a user can vote form (via a submission form). Currently, each poll question is stored as a page with each choice being a child of the Poll page (as seen below). Additionally, each choice has a "votes" field which tracks the number of votes a particular choice gets.

--Poll

----Choice 1

----Choice 2

----Choice 3

However, I'm unsure how to limit the number of times a user can vote on a particular poll. Ideally, I would like to allow a user to vote once a day (every 24 hours), so I'm assuming I would have to do this by logging the user's IP address each time a vote is cast. I'm assuming that this would need to be done automatically by the voting function and I would need to track this by adding a "Vote Tracker" child page or something similiar and adding child votes to it each time that would include an IP address and the date/time it was cast, however this seems a bit cumbersome, especially as I would need to make sure there was a "Vote Tracker" child for each Poll, sort of as seen below:

--Poll

----Choice 1

----Choice 2

----Choice 3

----Vote Tracker

------Vote1 (contains IP address)

------Vote2

------Vote3

------...etc

I guess I'm just curious if there is a better way to do this, or if there is any way to attach an array to each poll that could store the same information.

Thanks!

Link to comment
Share on other sites

Hi shawnadelic and welcome!

Check out soma's new module:

https://processwire.com/talk/topic/9299-pollino-simple-polls-for-processwire/

There really is no fool proof way of ensuring this sort of thing. Cookies can be cleared, IP addresses are usually not static and can be spoofed anyway. The best option is to require the user have a user account and that they be logged in, but if you are not concerned with complete accuracy, you can make use of a combination of techniques, which I believe soma's module allows for.

Even if the module doesn't suit your needs exactly, I bet you will find lots of useful code snippets and ideas in there.

I have built a couple of polls, one that relied solely on cookies, and one that required the users to be logged in, but have never gone the IP route, because in particular it might prevent users from the same house, place of work, or even the same ISP being able to vote.

  • Like 1
Link to comment
Share on other sites

Thanks for the reply!

It's not critical that the poll is 100% secure, so I'm trying to avoid requiring a login to allow as many people participate as possible. That being said, soma's IP logging in that module looks like exactly what I had in mind, so I am definitely going to check it out a little more closely. Thanks!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...