I have one specific warning in Drupal 7 from the workbench module which I do not want to display. All other warnings should not be changed.

For now I edit the workbench module by comment the specific line which is not the way it should be solved for final.

I tried to use disables messages wit a specific regex but this is not working. I think because it is a warning and not a message.

I prefer to use hook_page_alter but cannot find the specific warning in the $vars array.

Any suggestion for this or what approach and possibility is there to solve this?

1 Answer 1


Solved it in Hook_preprocess_page(&$vars) {

  $all_warnings = $_SESSION['messages']['warning'];
  foreach ($all_warnings as $nr => $messageinfo) {
      if (strpos($messageinfo,"do not have permission to moderate") != false){
        unset ($_SESSION['messages']['warning']);

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.