Add a message to messages array using theme process or preprocess function For testing purposes, I'm trying to manually add a message to the $messages array, in either process or preprocess page function. To be clear, I first tried using

template.php -&gt; mytheme_preprocess_page (&amp;$vars) {}


but then I realized there's no $messages array there, so instead I am doing it via process.page.inc. 

The code I have tried, which is not working is:

function mytheme_process_page(&amp;$variables) {
    $variables[messages][] = 'new test message';
    kpr($variables);  
}


I have tried some variations on this, but nothing worked.
$messages isn't an array of messages; it's the rendered output of theme_status_messages(). From the point at which you're looking to add messages (template_process_page()), Drupal has already processed all the messages it's going to render. 

If you're looking to print some debugging messages you can do something like this:

function MYTHEME_process_page(&amp;$variables) {
  drupal_set_message('new test message');

  //This will overwrite any previous messages that were to be rendered
  $variables['messages'] = theme_status_messages(array('display' =&gt; null));
}