Forum Replies Created

Viewing 1 replies (of 1 total)
  • Forum: Plugins
    In reply to: Poll Plugin for WordPress

    It looks like the header error is because of a conflict in the header.php file sending information before the setcookie(); command in poll.php. Apparently setcookie(); technically sends headers to the client computer similarly to normal http headers. If any content (i.e. “echo” commands or text) is sent to the client before setcookie(); is used, an error occurs.

    There are a couple ways to fix this, but a quick [and sloppy] hack is to edit the index.php file in your template and change:

    <?php get_header(); ?>
    <?php vote_poll(); ?>

    to

    <?php ob_start();
    get_header();
    vote_poll();
    ob_end_flush();
    ?>

    It fixes both the error that you’re seeing and also allows the cookie to function properly. In programming terms, it would be much better to re-code the polls.php and get the setcookie(); function to work earlier before any of the content is sent to the client. The ob_start(); and ob_end_flush(); basically creates a buffer for php to store all the information until the headers are fully established and then send the data to the client at once. So long as there isn’t a tremendous amount of stuff in the headers.php and poll.php files, everything should be ok.

    If anyone knows how to successfully re-code the polls.php file, any help would be appreciated (so that the hack isn’t required) ??

Viewing 1 replies (of 1 total)