Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How clear messages queue generated from drupal_set_message in popups api ajax in Drupal?

Tags:

drupal

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

like image 876
Iulian Boiculese Avatar asked Oct 21 '11 13:10

Iulian Boiculese


2 Answers

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

In 8.5.x there is a new Messenger service you can use. The drupal_get_messages() function will be deprecated.

Clearing all messages using the Messenger service:

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

like image 59
daggerhart Avatar answered Nov 19 '22 19:11

daggerhart


Drupal 7:

The messages are in $_SESSION if you want to clear for example the "status"-Messages you can do it like that:

if (isset($_SESSION['messages']['status'])) {
  unset($_SESSION['messages']['status']);
}
like image 40
Bernhard Zürn Avatar answered Nov 19 '22 19:11

Bernhard Zürn