How do I add view header content in code?
Use hook_views_pre_render().

/**
 * Implements hook_views_pre_render().
 */
function cv_views_pre_render(&amp;$view) {
  // dpm($view); // dpm view here to see its properties.
  // and replace $view-&gt;name and $view-&gt;current_display with actual values from your view.
  // Note that my example uses Global: Text area for header, that's why I use $view-&gt;header['area']. 
  // Other options available for header have different names. Try to find one that you use.
  if ($view-&gt;name == 'homepage' &amp;&amp; $view-&gt;current_display = 'homepage_page_display') {
    $view-&gt;header['area']-&gt;options['content'] = t('TEST message');
  }
}