Add hook_message_alter()

flobruit - March 14, 2008 - 19:15
Project:Drupal
Version:7.x-dev
Component:base system
Category:feature request
Priority:normal
Assigned:flobruit
Status:duplicate
Description

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).

AttachmentSizeStatusTest resultOperations
hook_message_alter.patch2.47 KBIgnoredNoneNone
hook_message_alter.documentation.patch1.06 KBIgnoredNoneNone

#1

Senpai - March 14, 2008 - 20:21

Subscribe.

#2

csevb10 - March 18, 2008 - 17:23

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

#3

Senpai - March 18, 2008 - 17:34

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.

#4

alanburke - February 3, 2009 - 16:23

+1 for this feature.

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

#5

Frando - February 3, 2009 - 16:33
Status:active» needs work

adjusting status. most likely needs a reroll.

#6

doq - May 12, 2009 - 22:00

Subscribing.

#7

Dave Reid - May 18, 2009 - 21:01
Status:needs work» duplicate

Duplicate of #127262: Proposed hook_message_alter.

 
 

Drupal is a registered trademark of Dries Buytaert.