WordPress.org

Ready to get started?Download WordPress

Forums

YOP Poll
Cookies and Showing Results (3 posts)

  1. _JamesW
    Member
    Posted 3 months ago #

    Hi, I have a couple of questions with how to set up my poll. What I want is just a standard poll - a simple question, and you can't see the results until you answer. After you've answered, you see the results and can't vote again.

    I can't seem to make that happen though.
    I had no problems with showing results after vote. To stop users voting again, I tried blocking with cookies. This didn't seem to work at all - it just has no effect.

    I tried blocking via cookie&IP but there are two problems. Firstly, it blocks people on the same network from voting. More importantly, when that person or someone else on the network comes back later, they don't see the results, just the question. But if they try to answer the question, they are told they aren't allowed to vote!

    Is there a known problem with the cookie blocking, and can I stop it showing an unanswerable question to people who already voted?

    Thanks!

    https://wordpress.org/plugins/yop-poll/

  2. YOP
    Member
    Plugin Author

    Posted 3 months ago #

    Hi _JamesW,

    If the voter uses a browser add-on that blocks cookies then blocking voters by cookie will not work. The same goes if the voter deletes the cookies after each vote.

    If you choose to block them by IP as well then users that share the same network will not be able to vote since they all have the same IP address.

    They will be able to vote again only when the interval you set in your poll options expires.

    Best wishes,

    YOP Team

  3. _JamesW
    Member
    Posted 3 months ago #

    So the problem was that cookies did not work at all, and that even with IP blocking it only recognised that the user had voted after they tried to vote again. After some digging I found the problems.

    A few issues with the code result in php notices. If the environment has error reporting on, these cause headers to be sent, and that means setcookie fails.

    There were also a couple of admin glitches which had similar causes.

    Here are some of the log entries that show the problems:
    [16-May-2014 10:01:52 UTC] PHP Notice: Undefined variable: feeditems in /wp-content/plugins/yop-poll/inc/admin.php on line 8714
    [16-May-2014 10:01:54 UTC] PHP Strict Standards: Non-static method Yop_Poll_Model::return_template_preview_html() should not be called statically, assuming $this from incompatible context in /wp-content/plugins/yop-poll/inc/admin.php on line 6974
    [16-May-2014 10:01:54 UTC] PHP Strict Standards: Non-static method Yop_Poll_Model::return_poll_css() should not be called statically, assuming $this from incompatible context in /wp-content/plugins/yop-poll/inc/yop_poll_model.php on line 2944
    [16-May-2014 10:02:46 UTC] PHP Notice: Trying to get property of non-object in /wp-content/plugins/yop-poll/inc/yop_poll_model.php on line 3713
    [16-May-2014 10:02:46 UTC] PHP Notice: Trying to get property of non-object in /wp-content/plugins/yop-poll/inc/yop_poll_model.php on line 3714
    [16-May-2014 10:02:46 UTC] PHP Notice: Undefined variable: log in /wp-content/plugins/yop-poll/inc/yop_poll_model.php on line 2238
    [16-May-2014 10:02:46 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /wp-content/plugins/yop-poll/inc/yop_poll_model.php:3713) in /wp-content/plugins/yop-poll/inc/yop_poll_model.php on line 3806
    [16-May-2014 10:02:46 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /wp-content/plugins/yop-poll/inc/yop_poll_model.php:3713) in /wp-content/plugins/yop-poll/inc/yop_poll_model.php on line 3807

    I made the following changes:
    admin.php
    6974 and 7016: Replaced Yop_Poll_Model::return_template_preview_html with $yop_poll_model->return_template_preview_html

    yop_poll_model.php
    2944: Replaced self::return_poll_css with $this->return_poll_css

    2238: Replaced undefined variable $log with a blank string - obviously this is not ideal.

    3713+ (is_ban): Added a check so we only attempt to read the user login and email if this is a logged in user.

    With these changes, cookie based blocking appears to work properly, and if the user comes back to the site after having voted, they see the results as intended.

Reply

You must log in to post.

About this Plugin

About this Topic