how to prevent warnings from displaying to anonymous users 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?
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 &gt; Configuration &gt; Development &gt; 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.