As in subject: how to prevent warnings from displaying to anonymous users? They contain paths etc. Even better, how to display warnings only to priviledged users?

  • Do you really want to prevent all warnings from displaying to anonymous users? remember that this includes important error messages like "incorrect password" for users that are currently anonymous but trying to log in... Commented Jun 30, 2012 at 16:56
  • Of course, not. The messages that are specifically for end users should still be shown. But I don't know how to differentiate them automatically (I'll check the module disable_messages mentioned below). And in any case, messages that contain paths and system errors should NOT be displayed to anonymous users.
    – camcam
    Commented Jul 2, 2012 at 6:27
  • Sure, in D6 I used drupal.org/project/messages_alter which provides a hook and a php class for matching/editing messages. Hasn't been ported to D7 yet so I can't really add this as an answer >.< Commented Jul 4, 2012 at 1:46
  • Feature request here drupal.org/node/2743119
    – giorgio79
    Commented Jun 6, 2016 at 7:40

1 Answer 1


First you should turn down the error_reporting options on your production server. This will erase most of PHP's warnings and notifications.

Also you can configure drupal to only log the errors. To do that go to Administration > Configuration > Development > Logging and errors or directly to the path /admin/config/development/logging and set "Error messages to display" to none. Drupal then still logs errors but doesn't display them to users.

If you still need finer control over messages surely the module disable_messages can help you.

  • 1
    If I set error_reporting e.g. to 0, will the errors still be visible in watchdog? The point is to hide them from users, but leave a trace of what happened to admins.
    – camcam
    Commented Jul 2, 2012 at 6:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.