1 bootstrap.inc backdrop_get_messages($type = NULL, $clear_queue = TRUE)

Returns all messages that have been set with backdrop_set_message().


string $type: (optional) Limit the messages returned by type. Defaults to NULL, meaning all types. These values are supported:

  • NULL
  • 'status'
  • 'warning'
  • 'error'
  • 'info'

bool $clear_queue: (optional) If this is TRUE, the queue will be cleared of messages of the type specified in the $type parameter. Otherwise the queue will be left intact. Defaults to TRUE.

Return value

array: A multidimensional array with keys corresponding to the set message types. The indexed array values of each contain the set messages for that type. The messages returned are limited to the type specified in the $type parameter. If there are no messages of the specified type, an empty array is returned.

See also




core/includes/bootstrap.inc, line 2451
Functions that need to be loaded on every Backdrop request.


function backdrop_get_messages($type = NULL, $clear_queue = TRUE) {
  if (backdrop_show_messages() && $messages = backdrop_set_message()) {
    if ($type) {
      if ($clear_queue) {
      if (isset($messages[$type])) {
        return array($type => $messages[$type]);
    else {
      if ($clear_queue) {
      return $messages;
  return array();