Removing Duplicates with hook_views_prerender I have a view (filtering on content) that is returning duplicates. I am trying to used hook_view_prerender to remove those duplicates... but even after running this, I still get duplicates... Any ideas? Here's my function (and yes I know the function is running):


function customedm_views_pre_render(&amp;$view) {
  $used_nids = array();
  if ($view->name == 'new_resources'){
    echo ('hi');
    foreach ($view->result as $row){
        if (!in_array($row->nid, $used_nids)) {
          $new_view_result[] = $row;
          $used_nids[] = $row->nid;
        }
      }
    $view->result = $new_view_result;
    }
  }
You do not need to do this - simply use Distinct.

Edit the View, open the Advanced section -> Query Settings -> check the "Distinct" checkbox and save the view.

Edit:
In case you do use Distinct already, there are some cases where this can occur. Here is an issue discussing this - https://www.drupal.org/node/1765730, and this one has a code example that manipulates the result similarly to what you are trying to do - https://www.drupal.org/node/1223448#comment-4757898