Which Views hook do I use to alter the view results page before it loads? I have a view that I want to change two items right before the page loads - the title, and the zipcode that determins the location to filter by.

My module detects a person's location and replaces the default value in the Views filter so that the results are properly sorted by that area.

So, the title changes to 'Viewing items around Charlotte, NC' where Charlotte, NC is the dynamic element.

I have created a module, but I am not sure what views hooks I need to use to achieve the results, especially getting the view to execute with the new location.

Here are the views hooks for D7
http://api.drupal.org/api/views/views.api.php/group/views_hooks/7

Do I pre_view it? pre_render? Alter the query with the new location details before its executed?

Here is a sample of my module trying to use hook_views_pre_view

function zipcode_filter_views_pre_view  ( &amp;$view, &amp;$display_id, &amp;$args) {

    $view = views_get_view('baby_clothes_pages');
    $view-&gt;set_display('default'); 
    $view-&gt;set_exposed_input(array('postal_code' =&gt; $zipcode));
    $view-&gt;display['default']-&gt;handler-&gt;options['title'] = $title;

}


note: this reference influeced the code I used. However, the documentation is wanting. Am I even on the right track with this? http://groups.drupal.org/node/10129
The answer was to remove the views_get_view function as well as the set->display function. There was also no need to try to execute the exposed input. All that was needed is to simply set the default values for the variables I wanted in the views_pre_view hook, and then Views takes care of the rest as it finishes doing its thing. Here is the resulting, correctly working code:

function zipcode_filter_views_pre_view  ( &amp;$view, &amp;$display_id, &amp;$args) {

    $view-&gt;display['default']-&gt;handler-&gt;options['title'] = "this is the new title";
    $view-&gt;exposed_input['distance']['postal_code'] = $_SESSION['zipcode_filter']['zip'];
    $view-&gt;exposed_input['distance']['search_distance'] = $_SESSION['zipcode_filter']['distance'];

}


Although, I don't understand why this works - Why do I not need to specify a display? Why did having the other parts of earlier code cause it to not work properly?