Changing values in preprocess view function I want to preprocess view to alter a field based on another field. I am able to print the value but not change it.

I did this:

function MYTHEME_preprocess_views_view__VIEWNAME(&amp;$vars){

     kpr($vars['view']-&gt;result['0']-&gt;field_field_name[0]['rendered']['#markup']);
}


Which prints the correct value.
But when I try to change/unset the value it does not work. Both of these do not work.

 unset($vars['view']-&gt;result['0']-&gt;field_field_name[0]['rendered']['#markup']);

 $vars['view']-&gt;result['0']-&gt;field_field_name[0]['rendered']['#markup'] = '';


I also tried another way  which prints the value but does not change it:

 unset($vars['view']-&gt;result['0']-&gt;_field_data['nid']['entity']-&gt;field_name['und'][0]['value']);


Note: I am rewriting the results of a field with view UI.
The MYTHEME_preprocess_views_view($vars) hook is executed at the end of the process to build a view. The purpose of the views_view.tpl.php is a general wrapper for all elements of the view. The result of fields have been builded and rendered and they have been stored in the variable $vars['rows'].

If you want to change, alter, unset a view, we can do in different phases. Between them, i've chosen the pre-render phase:

function HOOK_views_pre_render(&amp;$view) {
  if(isset($view-&gt;name) &amp;&amp; $view-&gt;name == 'YOUR_VIEW'){
    // kpr($view);
    foreach($view-&gt;result as $r){
      $r-&gt;field_field_NAME[0]['rendered']['#markup'] .= '. ADDING TEXT TO CHANGE THE RESULT';  
    }
  }
}


These are the stages that are given by Views API (you will find it in the views folder). Maybe one of them is more useful:

hook_views_pre_view(&amp;$view, &amp;$display_id, &amp;$args) {}



  Allows altering a view at the very beginning of views processing, before
    anything is done.




hook_views_pre_build(&amp;$view)



  This hook is called right before the build process, but after displays
    are attached and the display performs its pre_execute phase.




hook_views_post_build(&amp;$view) {}



  This hook is called right after the build process. The query is now fully
    built, but it has not yet been run through db_rewrite_sql.




hook_views_pre_execute(&amp;$view) {}



  This hook is called right before the execute process. The query is now fully
    built, but it has not yet been run through db_rewrite_sql.




hook_views_post_execute(&amp;$view) {}



  This hook is called right after the execute process. The query has
    been executed, but the pre_render() phase has not yet happened for
    handlers.




hook_views_pre_render(&amp;$view) {}



  This hook is called right before the render process. The query has been
    executed, and the pre_render() phase has already happened for handlers, so
    all data should be available.




hook_views_post_render(&amp;$view, &amp;$output, &amp;$cache) {}



  Post process any rendered data.