Use views to display not voted polls I'm using polls (from core) to make some enquetes.
Is there a way to use views to display only the polls that a user has not voted yet?

I didn't find anything on google. The only solutions where for Drupal 6. And I'm using drupal 7.

Thanks in advance =)
First I tried to use the hook_views_pre_execute.

&lt;?php    
function hook_views_pre_execute(&amp;$view) {
    $uid = $GLOBALS['user']-&gt;uid;

    //gets one the poll and return it
        $query = db_select('node', 'n');
        $query-&gt;fields('n');

        $subquery = db_select('poll_vote', '');
        $subquery-&gt;fields('poll_vote', array('nid'));
        $subquery-&gt;condition('poll_vote.uid', $uid);

        $query-&gt;condition('n.nid', $subquery, 'NOT IN');
        $query-&gt;condition('type', 'poll');
        $query-&gt;condition('status', 1);
        $query-&gt;range(0, 1);

    $view-&gt;build_info['query'] = $query;
    $view-&gt;build_info['count_query'] = $query;
}


But when I tried to use the pager, it had too many bugs. It felt like a hack. So in the end I used:

&lt;?php
/**
 * Returns a page with one not voted poll
 * @return [array] [drupal page array]
 */
function one_poll_page(){

    $page[] = "";
    $uid = $GLOBALS['user']-&gt;uid;

    //gets one the poll and return it
        $query = db_select('node', 'n');
        $query-&gt;fields('n');

        $subquery = db_select('poll_vote', '');
        $subquery-&gt;fields('poll_vote', array('nid'));
        $subquery-&gt;condition('poll_vote.uid', $uid);

        $query-&gt;condition('n.nid', $subquery, 'NOT IN');
        $query-&gt;condition('type', 'poll');
        $query-&gt;condition('status', 1);
        $query-&gt;range(0, 1);

        $result = $query-&gt;execute();

    foreach ($result as $record) {
      //saves the rendered poll node to the array
      $node = node_load($record-&gt;nid);
      $view = node_view($node, 'full');
      $rendered = drupal_render($view);
      $page['#markup'] .= $rendered;
    }

    return $page;
}


Because I can then control exactly what the page does.