tags:

views:

74

answers:

3

Whenever a content item is created, a message is displayed like this:

[Content Type] [Name] has been created.

Is there any way to disable this message for specific users? Or for all users would be fine too.

A: 

It's node_form_submit that is creating those messages. You could pretty easily use hook_form_alter on the node form and use your own version of node_form_submit instead. All you would need to do, would be to copy the function and add an user_access('whatever') check before that message is created.

Alternatively, you could in preprocess_page function, check which messages is being served, and remove unwanted ones, but that would be a bit more tricky. Should be possible with some regex. On the other hand, this method would be a bit more upgrade friendly, since you could remain using the node_form_submit function and would get future changes if any.

googletorp
A: 

If you want to use the Rules module, then you can use the new module I created called "Better Rules Message". By using this you can setup a rule that will delete all of the messages after a node is being created...

Hopefully this will be added to the main Rules module in the near future.

Shushu
+1  A: 

googletorp is right (about the submit function). But unfortunately you can't decouple the message from the node submit function and duplicating the functionality (without the message) is going to mean your site might break when a security release is issued. You'd have to maintain your own version of that function. It's probably not a big deal but it's a good idea to follow best practice.

You'll need to write your own submit hook either before or after node_form_submit gets called.

With a submit hook after the node save, you could remove the message from $_SESSION['messages'] if the messages array was easy enough to work with. I imagine that would be simple enough. See drupal_set_message

OR

You could write some class in CSS in your body tag and set the display to none when status messages are returned on the page that the node form submits to. But that might put your business logic in your theme layer which should be avoided.

Rimian

related questions