How to change a grouping field in a view programmatically?
function MYMODULE_views_pre_build( &amp;$view ) {
  $custom_field = 'field_MYFIELD_value';
  $view-&gt;display[$view-&gt;current_display]-&gt;handler-&gt;options["style_options"]["grouping"] = $custom_field;
}