Being able to alter messages set with drupal_set_message() is a simple but relatively important feature for sites where a high level of customization is required. Currently, messages are stored in the $_SESSION variable without an array index that could be used to identify them.

The first patch adds a $message_id parameter to drupal_set_message(). This parameter is redundant with the current $repeat parameter which is only used once in drupal core. A call to hook_message_alter is added inside of drupal_get_message().

The second patch provides documentation for the new hook_message_alter().

This first step consists of making messages identifiable and alterable with hook_message_alter(). The second step will be to add message id's to drupal_set_message() calls where appropriate (messages of type 'error' should probably not have a message id, we generally don't want to make them alterable).

Comments

senpai’s picture

Subscribe.

csevb10’s picture

I'm all for it. Modifying messages at the moment is a pain and hacky at best. +1

senpai’s picture

Having just modded yet another version of a drupal_set_message error that shows up inside the user_login block, I feel compelled to agreed with csev in #2.

I'll test this out later today and RTBC it.

alanburke’s picture

+1 for this feature.

Would appreciate any tips / links on how to do this in Drupal 6 for now.

Frando’s picture

Status: Active » Needs work

adjusting status. most likely needs a reroll.

doq’s picture

Subscribing.

dave reid’s picture

Status: Needs work » Closed (duplicate)