There is, by default, no way to totally remove status messages from a page.

Even if the Messages block is disabled or removed from the page theme, Drupal injects the status messages in the page via the BlockPageVariant build method:

    // If no block displays status messages, still render them.
    if (!$messages_block_displayed) {
      $build['content']['messages'] = [
        '#weight' => -1000,
        '#type' => 'status_messages',
        '#include_fallback' => TRUE,
      ];
    } 

This module implements a hook_preprocess_page which removes the messages render array for a specific set of page URLs.

Use case: do not display status messages on a page triggering an immediate redirect, rather display them after the redirection has occurred.

Configuration

Go to /admin/config/system/remove_status_messages/settings and enter one internal path per line, such as /node/1, not a path alias. The * character is a wildcard and <front> is the front page. The messages removed from a matching page show on the next page instead. A Messages block placed in the theme is left alone.

Issue credits will only be granted for significant contributions.

Supporting organizations: 
Development

Project information

  • caution Minimally maintained
    Maintainers monitor issues, but fast responses are not guaranteed.
  • caution Maintenance fixes only
    Considered feature-complete by its maintainers.
  • chart icon26 sites report using this module
  • Created by mably on , updated
  • shieldStable releases for this project are covered by the security advisory policy.
    Look for the shield icon below.

Releases