bookmark_borderHow Poll Results Work, And Why They May Be Delayed

In rare cases, poll results may not appear to be accurate when using the Polls add-on. In this article, we will explain how the poll results are generated, any why they may be delayed.

How Poll Results Are Generated

Each time a submission occurs, results are processed. Those processed results are then displayed to the user. The results are then cached until another submission triggers them to need to be rebuilt again.

Why Are My Results Not Updated?

In some rare cases, when there are thousands of submissions, on a particular poll, the results may not be able to be generated quickly.

If results take longer than 5 seconds to generate, a cron is created which will attempt to rebuild the results hourly. Once the cron is created, it will attempt every hour to complete the result generation.

Simply giving some time for the results to be generated will the data to once again become accurate.

Can I Make Attempts Sooner?

Yes. With a bit of custom code, you can adjust the cron task to run more often. For example, a failure could attempt twice an hour rather than hourly. The snippet below will allow you to do so:

add_filter( 'gform_polls_cron_schedule', 'cron_add_twice_hourly' );
function cron_add_twice_hourly() {
    // Adds once weekly to the existing schedules.
    $schedule['twicehourly'] = array(
        'interval' => 1800, // number of seconds in the interval
        'display' => __( 'Twice Hourly' )
    );
    return $schedule;
}

Note: After inserting this snippet, you will need to deactivate and reactivate the Polls add-on to reschedule an existing task.