function drupal_set_message

cis7 bootstrap.inc drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE)
cle7 bootstrap.inc drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE)
elmsmedia7 bootstrap.inc drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE)
icor7 bootstrap.inc drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE)
meedjum_blog7 bootstrap.inc drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE)
mooc7 bootstrap.inc drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE)

Sets a message to display to the user.

Messages are stored in a session variable and displayed in page.tpl.php via the $messages theme variable.

Example usage:

drupal_set_message(t('An error occurred and processing did not complete.'), 'error');

Parameters

string $message: (optional) The translated message to be displayed to the user. For consistency with other messages, it should begin with a capital letter and end with a period.

string $type: (optional) The message's type. Defaults to 'status'. These values are supported:

  • 'status'
  • 'warning'
  • 'error'

bool $repeat: (optional) If this is FALSE and the message is already set, then the message won't be repeated. Defaults to TRUE.

Return value

array|null A multidimensional array with keys corresponding to the set message types. The indexed array values of each contain the set messages for that type. Or, if there are no messages set, the function returns NULL.

See also

drupal_get_messages()

theme_status_messages()

712 calls to drupal_set_message()
accessibility_tests_list_done in sites/all/modules/ulmus/accessibility/accessibility.admin.inc
Batch import finished callback.
accessibility_test_delete_form_submit in sites/all/modules/ulmus/accessibility/accessibility.module
Submit callback for model_delete_form
action_nodequeue_add in sites/all/modules/local_contrib/nodequeue/includes/nodequeue.actions.inc
Old-style action to add a node to a queue.
adaptivetheme_form_system_theme_settings_alter in sites/all/themes/ulmus/adaptivetheme/at_core/theme-settings.php
@file Implimentation of hook_form_system_theme_settings_alter()
admin_devel_form_admin_menu_theme_settings_alter_rebuild_submit in sites/all/modules/ulmus/admin_menu/admin_devel/admin_devel.module
Form submit handler to wipe and rebuild all 'module' = 'system' menu links.

... See full list

2 string references to 'drupal_set_message'
devel_generate_set_message in sites/all/modules/ulmus/devel/devel_generate/devel_generate.module
Set a message for either drush or the web interface.
devel_set_message in sites/all/modules/ulmus/devel/devel.module

File

includes/bootstrap.inc, line 1777
Functions that need to be loaded on every Drupal request.

Code

function drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE) {
  if ($message) {
    if (!isset($_SESSION['messages'][$type])) {
      $_SESSION['messages'][$type] = array();
    }

    if ($repeat || !in_array($message, $_SESSION['messages'][$type])) {
      $_SESSION['messages'][$type][] = $message;
    }

    // Mark this page as being uncacheable.
    drupal_page_is_cacheable(FALSE);
  }

  // Messages not set when DB connection fails.
  return isset($_SESSION['messages']) ? $_SESSION['messages'] : NULL;
}