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.

Comments

richard.diejomaoh’s picture

Please can anyone show me where I can get a documentation on how to use the "Disable Messages module"

zyxware’s picture

Can you please clarify on what exactly you need help with?

Here is some more details.

Once you install the module you can see the configuration options at admin/settings/disable-messages. Most of the controls have detailed instructions. You have to enable filtering by checking the checkbox, then add regex rules to match messages you wish to not show to the end user in the "Messages to be disabled:" textarea.

You can limit the application of this filtering by specific roles. There is an "exclude from message filtering" permission that will turn off filtering for that particular role. There are also permissions for the different types of messages that you wish to restrict from specific roles.

You can also apply filters by paths which follows a similar path limiting logic as normally used in Drupal admin like for example in block configuration.

Then there is an option to disable any filtering for specific user ids (eg: to show all messages for a few admin users). You can do this by adding the ids (comma separated) to "Users excluded from filtering: " text box.

You can enable "Enable debug mode" checkbox to show the messages in a hidden div in the page footer so that you can actually inspect messages and the hide/show logic used if you wish to. In addition you can make this hidden div visible while you are debugging the regex you used to filter the messages.

MakeOnlineShop’s picture

Hello,

Can you tell me what I should type in the module box if I want to hide confirmation messages when a page is created ?

The messages shown are:

Page xxxxxxx has been created.

And I would like that the user doesn't see it.

Thanks a lot.

wxman’s picture

I truly stink at these, but try:

(?=.*?\bPage\b)(?=.*?\bhas been created\b).*
lpc’s picture

try

[Page].*[has been created.]

iRex’s picture

I'd like to remove the title on a conte creation page/form: Create (content type name). Can it be done using this module, and if it can, what is the correct syntax? I've tried the following without success:

Create [Page]
Create [Page].*

... this Rock...

iRex’s picture

I used the Exclude Node Title module and it worked like a charm. Thanks

... this Rock...

zyxware’s picture

No, this cannot be done using the Disable Messages module. What you are looking for is to remove the title of the page. This will have to be done using a custom preprocess_page function and a drupal_set_title call to set it to something else. Like iRex pointed below the http://drupal.org/project/exclude_node_title module will do this without programming.

However the message -

Page 'title' has been created

can be removed using Disable messages module. You can use the following regular expression to do this

Page .* has been created.

Remember to put the last dot as well

kpv’s picture

Page .*? has been created.

bixgomez’s picture

I have installed this module. But going to /admin/settings/disable-messages/ just takes me to the main "Administration" page.

_ib’s picture

admin/config/development/disable-messages

McSukkelaar’s picture

Be sure to clear the cache for the module to appear in your settings.

otcassetmgmt’s picture

I want to disable the notice messages? I entered in the box

Notice: Undefined property:

But they still appear

rustenrat’s picture

Hi, great module, thanks a lot. Saved me a ton of time. I have searched the net for info on the different message types that it's possible to filter under permission settings, but I'm just getting more confused.
Can you tell me what is filtered via the permission settings in your module, ie what are

  • Status - only phhp messages or7and also "Node succesfully created-type messages?
  • Warning - php or node-not created type messages?
  • error -only php errors or ?

Thanks in advance

McSukkelaar’s picture

Truly brilliant module! This has saved me a lot of time. Thanks a lot!

andreiianusco’s picture

Can anyone tell me what the regex would be for xyz added to your shopping cart. provided by the Ubercart Module?

Thanks,
Andrei

Alauddin’s picture

add this is the 'messages to be disabled box'

^.*strict warning.*\.
^.*Notice.*\.

users excluded from filtering...just enter 1 for user1

Keep your settings on config/development/logging to 'display all messages'

Now user1 will see the notices and strict warnings but not others.

bdupls’s picture

On Drupal commons, there is a standard message commons_activity_streams_node_created that is sent to members of a group when new content is created. I have added the option on the 'add content' form to disable this feature. I have added rules which work on previously created posts when they are edited and the option to not send and email is checked. But I can't stop the initial 'commons_activity_streams_node_created' message from being sent out. I thought this disable message module would work to disable the messages by adding the Message to be disabled i.e. commons_activity_streams_node_created
But it doesn't work. Am I on the wrong track with this module expecting it to disable the email from being sent. Not sure how else to handle this. Any ideas would be appreciated.

bdupls’s picture

It appears that no this is not the right module, however I did find this one useful.
I sorted out my email notification with additional rules.

FireHawkX’s picture

Hi,
I am trying to get rid of a message that will most likely never be fixed...

here is the full message displayed unedited :
"Warning: Declaration of paragraphs_handler_relationship::options_form(array &$form, array &$form_state) should be compatible with views_handler_relationship::options_form(&$form, &$form_state) in include_once() (line 3518 of C:\DrupalLocalStuff\drupal-7.65\includes\bootstrap.inc)."

I tried keeping it simple :
.+Warning.+Declaration of paragraphs.+

but it doesnt work the message still keeps appearing all over the place all the time :)

Steff Vanhaverbeke’s picture

Try this:
Warning\: Declaration of .*