drupal_get_messages

Versions
5 – 7
drupal_get_messages($type = NULL, $clear_queue = TRUE)

Return all messages that have been set.

Parameters

$type (optional) Only return messages of this type.

$clear_queue (optional) Set to FALSE if you do not want to clear the messages queue

Return value

An associative array, the key is the message type, the value an array of messages. If the $type parameter is passed, you get only that type, or an empty array if there are no such messages. If $type is not passed, all message types are returned, or an empty array if none exist.

▾ 2 functions call drupal_get_messages()

page_set_cache in drupal/includes/common.inc
Store the current page in the cache.
theme_status_messages in drupal/includes/theme.inc
Return a themed set of status and/or error messages. The messages are grouped by type.

Code

drupal/includes/bootstrap.inc, line 807

<?php
function drupal_get_messages($type = NULL, $clear_queue = TRUE) {
  if ($messages = drupal_set_message()) {
    if ($type) {
      if ($clear_queue) {
         unset($_SESSION['messages'][$type]);
      }
      if (isset($messages[$type])) {
        return array($type => $messages[$type]);
      }
    }
    else {
      if ($clear_queue) {
         unset($_SESSION['messages']);
      }
      return $messages;
    }
  }
  return array();
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.