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).
| Comment | File | Size | Author |
|---|---|---|---|
| hook_message_alter.documentation.patch | 1.06 KB | floretan | |
| hook_message_alter.patch | 2.47 KB | floretan |
Comments
Comment #1
senpai commentedSubscribe.
Comment #2
csevb10 commentedI'm all for it. Modifying messages at the moment is a pain and hacky at best. +1
Comment #3
senpai commentedHaving 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.
Comment #4
alanburke commented+1 for this feature.
Would appreciate any tips / links on how to do this in Drupal 6 for now.
Comment #5
Frando commentedadjusting status. most likely needs a reroll.
Comment #6
doq commentedSubscribing.
Comment #7
dave reidDuplicate of #127262: Proposed hook_message_alter.