enter image description hereI want to hide error and warning message from admin panel. I have checked the option None in admin panel for error reporting and still it showing error and warning messages in admin panel. let me how it can removed.


The code suggested by indrock would remove all the messages shown by the modules, not just error messages, and warnings.

What you can do is implement THEME_preprocess_HOOK() using the following code.

function mytheme_preprocess_page(&$variables) {
  if (path_is_admin(current_path())) {

current_path() currently returns the value of $_GET['q']; I am using it for compatibility with Drupal 8, as for that version current_path() is not simply returning the value of $_GET['q'].
Instead of unset($_SESSION['messages'][$type]), you can use drupal_get_messages($type, TRUE). Using drupal_get_messages(), you are sure your code works even when the messages are stored in a different session variable, or a variable that is a session variable. So far, it doesn't seem necessary, as Drupal 8 uses the same session variables used from Drupal 7, for the messages.

The settings in admin/config/development/logging are for error messages caused by PHP code. They don't influence the error messages shown by modules.

| improve this answer | |
  • this gives more control on the type of messages. A better solution ;-) – AjitS Sep 23 '12 at 14:59

Although it is not a good idea to hide the errors (you may want to solve it; by watching the error log, debugging etc.), there is a way you can do it.

You can do it at theme level in template_process_page() function, in your theme's template.php file. (It should be placed in your admin theme's template.php)
Code: Edited according to @Chapabu 's comments :)
Used path_is_admin() and current_path().


function MYTHEME_process_page(&$variables) {
  if (path_is_admin(current_path())) {

| improve this answer | |
  • i think it will unset this for whole site while i want it only for admin panel – Pramod Kumar Sharma Sep 11 '12 at 8:53
  • look for the edit. Don't forget to clean the caches :) – AjitS Sep 11 '12 at 8:59
  • I have tried the way you mention but it still showing errors on admin panel configuration as shown in the screenshot in question...plz have a look – Pramod Kumar Sharma Sep 11 '12 at 9:17
  • 1
    Don't forget you'll need to put this code in the template.php for the admin theme, not the for your site theme! – Chapabu Sep 11 '12 at 11:07
  • 1
    Also, I'd replace if (arg(0) == 'admin') with if (path_is_admin(current_path())) just in case you're on an admin page that doesn't start with admin (such as the feed importer page) – Chapabu Sep 11 '12 at 11:10

To hide Error and Warnings using Admin panel goto


Select None to hide errors.

| improve this answer | |

You can only make it so that the error shows on certain usernames, because sometimes they do give out helpful information like "Module Update reminder" etc.

function MYTHEME_process_page(&$variables) {
  global $user;
  if (path_is_admin(current_path()) == TRUE) {
    if(!in_array($user->name,array('username1','username2'))) {
       $variables['show_messages'] = FALSE;

You can replace/add to array username1 and username2 with whatever usernames you would wish to show the error messages to.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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