How is an explicit message queue generated from drupal_set_message in popups ajax api in Drupal?

How to clear message queue generated from drupal set message when ajax api popup windows are open in Drupal?

+4
source share
2 answers

Drupal 5-8: running drupal_get_messages () will clear the messages.

8.5.x has a new Messenger service that you can use. The drupal_get_messages() function will be deprecated.

Delete all messages using the Messenger service:

$messages = \Drupal::messenger()->deleteAll();

+11
source

Drupal 7:

Messages are in $ _SESSION, if you want, for example, clearing "status" -Messages, you can do it like this:

 if (isset($_SESSION['messages']['status'])) { unset($_SESSION['messages']['status']); } 
0
source

All Articles