function drupal_set_message

cis7 drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE)
cle7 drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE)
elmsmedia7 drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE)
icor7 drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE)
meedjum_blog7 drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE)
mooc7 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');


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



712 calls to drupal_set_message()
accessibility_tests_list_done in sites/all/modules/ulmus/accessibility/
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/
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


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


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.

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



Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/ in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/
The website encountered an unexpected error. Please try again later.