Closed (fixed)
Project:
Drupal core
Version:
6.x-dev
Component:
other
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
3 Dec 2008 at 14:22 UTC
Updated:
6 Jun 2016 at 07:59 UTC
Jump to comment: Most recent
Comments
Comment #1
sumitshekhawat7331 commentedhi just remove this line from your page.tpl.php
Comment #2
ultimateboy commentedThe above will remove error messages for all users, which usually is not a good thing. The problem is that drupal has a very narrow way of classifying messages. There really are only three options: status, error, and warning. Therefore there is no easy way to classify that a certain type of message be removed without harmful side effects. PHP and mySQL errors have a type of "error", but so does not filling in a required field in a form... so you cannot classify that way. I honestly do not think there would be a way to achieve the effect you are looking for without adding more parameters to drupal_set_message(), which is an interesting idea, but at this time, I do not see this as being a huge problem that needs solving at this point in time. It is my opinion that a site should not launch with php and mysql errors...
Comment #3
ultimateboy commentedActually, won't fix is probably a better classification.
Comment #4
kenorb commentedLooking for it as well.
You can classify it by looking for some phrases and ignoring all messages which contains some errors or security information:
etc.
I think it can be done somehow.
Comment #5
kenorb commentedMy temporary quick-fix in page.tpl.php file;)
if ($show_messages && $messages != ""):print $messagesendif;Related to this bug: #331651: db_rewrite_sql improperly rewriting a subquery
Comment #6
ultimateboy commentedError message handling has been improved in d7.
Marking as duplicate of the now committed patch: http://drupal.org/node/291026
Comment #7
kenorb commentedStill looking for some solutions for 6.x
Comment #8
grobemo commentedKeeping in mind the warnings that everyone gave above, if you still want to hide messages from anonymous users, you could change this line in page.tpl.php:
to this:
This would hide all messages from anonymous users, though—not just error messages. Anyone know how to refine it to show, say, status messages, but not error messages or warnings?
Comment #9
szy commentedSorry, now I see it's duplicate :/
Szy.
Comment #10
kenorb commentedgrobemo: I know how to refine it to show, look #4
Comment #11
mariagwyn commented@grobemo: can this be refined to specify user role? Like only for admin or site editor roles?
Thanks,
Maria
Comment #12
grobemo commentedYes, though anything beyond checking for administrator status starts getting to the point where you should think about moving the code to template.php.
To restrict messages to the administrator:
To restrict to a particular role (e.g., 'editor'):
Restricting to any of several roles is a bit more complicated. See the PHP documentation for in_array(), especially the first comment (by Thingmand).
Comment #13
kenorb commentedFor me it's not duplicate, can't use patches from 7.x on 6.x
There are already some solutions in this thread, any more ideas?
Comment #14
dropchew commentedTo #8
Is using Css class to hide status, error or warnings a good idea? I can see there's an css class 'error' for error messages, not sure about status and warnings...
Btw subscribing, what I need is to restrict messages on certain pages only, does anyone have a solution?
Comment #15
grobemo commentedHmm...I'm #8, but I'm not sure why this question is directed at me. I'm also not sure whether the question is rhetorical or not—that is, whether you mean to suggest that using CSS is not a good idea. But for what little it's worth, here's my two cents:
Hiding messages with CSS is easy. Messages come wrapped in divs with the class messages. Errors, as you note, have the class 'error', warnings have class 'warning', and I'm pretty sure status messages have class 'status'. The following CSS declaration would hide all messages:
As I see them, the advantages of hiding messages via CSS are that it's an easy to do and that you can still see the messages by looking at source code, which means that you (the developer) can still see what Drupal is telling you, even when viewing your site as an anonymous user. The main disadvantage is that "real" anonymous users could also see what Drupal is telling you by looking at the source code. At best, that's slightly unprofessional; at worst, it might make security breaches easier.
If your site is really working the way you want it to, it shouldn't really matter, since users shouldn't be generating messages that you don't want them to see anyway. (I realize that this is easier said than done!)
If other people have thoughts on that, please share.
As for hiding messages on certain pages, I don't know whether Drupal feeds messages through a specific template. You could try something like the following in the THEME_preprocess_page function of your theme's template.php:
That should prevent messages from displaying on any page that meets CONDITION. (For instance, if CONDITION is
!user_is_logged_in(), this snippet should hide messages from all anonymous users.)Comment #16
kenorb commentedAs discussed in #4 I finally found some time:
Drupal Tweaks
You can select which messages you can hide and for which role from UI (done programmatically, not by CSS).
Comment #18
ikeigenwijs commentedJust to keep track of this issue
Comment #19
Ross-Hunter commented#16 solves this problem pretty well. Thanks!
Comment #20
interestingaftermath commentedAny way to just hide error messages from anonymous users not ALL messages?
Comment #21
tourendal commentedsubscribe
Comment #22
tyler.frankenstein commentedUse theme_status_messages(), for example:
Inside the for loop...
The above code will skip the rendering of all error messages for anonymous users.
Comment #23
anoopjohn commentedYou can use the module - http://drupal.org/project/disable_messages - to hide messages from anonymous users.
Comment #24
ywarnier commented#22 works well for me. Thanks @tyler.frankenstein
Comment #25
beto_beto commentedGo to Administer > Site configuration > Error reporting (admin/settings/error-reporting). There you have a dropdown list under 'Error reporting' with the two choices you have for the error logging, being:
Write errors to the log.
Write errors to the log and to the screen.
The page even contains a hint to guide you in the right direction:
Where Drupal, PHP and SQL errors are logged. On a production server it is recommended that errors are only written to the error log. On a test server it can be helpful to write logs to the screen.
Just choose 'Write errors to the log.' and your visitiors won't be bugged by (to them) meaningless error messages.
you can read this link it's useful :
http://www.drupalcoder.com/blog/disable-error-reporting-to-the-screen-on...
Comment #26
giorgio79 commentedFeature request here #2743119: Option to display php error messages in a block so we can limit visibility per role