Advertising sustains the DA. Ads are hidden for members. Join today

Disable / Hide messages shown to end users

You are browsing documentation for an older version of Drupal, which is not supported any longer, and the information may not be correct. See current documentation for Contributed modules

Drupal core and the various contributed modules communicates back to the site users using a simple messaging framework that stores all messages into the users session and then outputs them together as $messages in page.tpl.php.

Site owners however do not necessarily like to show all the messages generated by the system. Hacking code to disable the drupal_set_message call is not a recommended approach as you will end up having to maintain a lot of patches just to disable/hide certain messages.

The module Disable Messages does exactly this. It allows site owner to disable specific messages shown to end users. This module gives site administrators a reasonably powerful way to filter out messages shown to the end users.

Features

  • Filter out messages that match a full text string exactly.
  • Filter out messages that match a regular expression(PCRE).
  • Permissions to specifically hide all messages of a given type from any role.
  • Disable all filtering for specific users.
  • Disable all filtering for specific paths.
  • Apply filtering only for specific paths.
  • Debug system to get messages in the HTML without showing it to the end users.

Tip: Keep it simple.
Be aware that something that appears very straightforward like:
Notice: Undefined index: field_txt_student_id in ctools_entity_form_field_content_type_render() (line 96 of [...]entity_form_field.inc).
Has a lot more unseen characters in it than one might expect:

<em class="placeholder">Notice</em>: Undefined index: field_txt_student_id in <em class="placeholder">ctools_entity_form_field_content_type_render()</em> (line <em class="placeholder">96</em> of <em class="placeholder">[...]entity_form_field.inc</em>).

So just wrap the meat of the grep with a simple "any character" regex: ".+" as in:

.+Notice.+Undefined index:.+ctools_entity_form_field_content_type_render.+entity_form_field.inc.+

Another simple example
To hide the message Page zzzz has been created use the filter rule:

Page .*? has been created.

Prevent the display of PHP's strict warnings with the Disable Messages module

If you're using Drupal 6 and you are on a server which is running PHP 5.4 you may see errors like:

Guide maintainers

zyxware's picture