How to filter a view relating node and user data? I created a content type called Vouchers. This content type has a field called: Points.

In the other hand I enabled the http://drupal.org/project/Userpoints module which allows users to get points.

I created 2 Vouchers nodes. One of them has the value 10 for the Points field and the other one 15

After, I created a view to show the content type: Vouchers. Now I need to add a filter to show the vouchers node only if its Points field value is lower than the User points value (the current logged user)

Please, look my capture to make this understandable:
You can add the same filter programmatically to your view.

/**
 * Implements hook_views_pre_view().
 */
function YOURMODULE_views_pre_view(&amp;$view, &amp;$display_id, &amp;$args) {
  if ($view-&gt;name == 'your_view_machine_name') {
    $info = array(
      'table' =&gt; 'field_data_field_points', // name of your “Points” field table.
      'field' =&gt; 'field_points_value', // name of value field in that table.
      'value' =&gt; array('value' =&gt; userpoints_get_current_points()), // dynamic part.
      'operator' =&gt; '&lt;',
      'id' =&gt; 'field_data_field_points_YOURMODULE', // unique id.
      'group' =&gt; 100, // new group.
    );
    $handler = views_get_handler($info['table'], $info['field'], 'filter');

    $handler-&gt;init($view, $info);
    $view-&gt;display_handler-&gt;handlers['filter'][$info['id']] = &amp;$handler;

    unset($handler);
  }
}


It will automatically join the table and add condition to query.