5

We're having a problem with the core poll module on drupal 7. We have a poll that we want anonymous users to be able to vote on. There is currently one anonymous vote, and now anonymous viewers only see the result (we've tried looking at it from outside our network).

We've checked the perms, and anonymous can vote and view results ( but not change vote). We've cleared the cache.

How does Poll work on D7 with regards to the anonymous user?

5

The problem is that the poll module only allows one vote per anonymous IP address. In the case of your hosting provider I suspect that they are using some sort of proxy that sends all requests to Drupal from the same IP address.

The Poll Enhancements Module modifies this behavior to allow multiple anonymous votes from the same IP address. The documentation on this module's description page also suggests the Poll Improved Module may solve this as well, but it does not have a production release at this time.

  • Confirming Poll Enhancements Module drush en pollanon. – leymannx Jun 23 '14 at 8:41
0

If it works anything like the drupal 6 version it stores a single vote per uid in the database. The anonymous user is user 0 so all anonymous votes are considered to be one user.

0

I try with the Brent's answer but this don't works for me, then i modified poll module of core D7.

This module block the votes for ip, then this lines change this:

file: home_site/modules/poll/poll.module

search the function "poll_vote" and add a random number to the ip address and replace it in the db_insert, like this:

$ip_random = mt_rand(0, 100000); $ip_real = ip_address(); $ip_new = $ip_real.".".$ip_random; global $user; db_insert('poll_vote') ->fields(array( 'nid' => $node->nid, 'chid' => $choice, 'uid' => $user->uid, 'hostname' => $ip_new, 'timestamp' => REQUEST_TIME, )) ->execute();

The module have a cache, then if u vote the browser will not let you vote again, but if u clean the cache or close the browser u can vote again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.