For example, if a user creates an image node, it would say "you have created an image ". I would really like to remove the title for those images - what would be the best way to do that without hacking core?

Comments

imranweb’s picture

Hi

No, absolutely not, you must never hack the core.

You may look at some form submit hooks to invoke after node form submission, where you can pass the customize message.

-Imran

VM’s picture

you can investigate the stringoverrides.module

Anonymous’s picture

Hi guys, thanks for your insightful comments.

(1) Could the node form submit message thing be accomplished with rules (and would that override the default one?)?
(2) For string override module, I'm trying to find that message with the exact placeholder though not 100% sure where its kept.. I need to use the exact string + placeholders to change the string, correct?

Anonymous’s picture

Ohh I found it:

@type %title has been deleted.

hockey2112’s picture

@type %title has been deleted.

This worked perfectly for me. Thanks!

VM’s picture

hacking core files to make this change isn't the best way forward. You will be relegated to having to hack core again and again with each update.

drupestre’s picture

Maybe you can find the solution here, it deals with overriding the node drupal set mesage :

Overwriting node has been createdupdated drupal set messages

Hope it helps.
Benoit

reszli’s picture

the above article describes 2 options to achive this scope:
+ one involves the String Overrides module - https://drupal.org/project/stringoverrides
+ the second helps you write your own custom module

but luckily, there is already a better / complete solutions:
+ Custom Submit Messages - https://drupal.org/project/csm
refer to the modules page for more details on what features it provides
and why it is a better / more general solution

Drupal Developer @Dropsolid

phponwebsites’s picture

You can solve this using hook_form_alter().

  function test_form_alter(&form, $form_state, $form_id) {
    if ($form_id == 'admin_form')   {
       $form['#submit'][] = 'test_hide_status_message'
    }
 }

 function test_hide_status_message(&$form, $form_state) {
   // To hide message
    drupal_get_messages('status');
  //To override message
    drupal_set_message('Hi welcome..!');
 }
Collins405’s picture

This is the best answer I have seen anywhere so far, its so simple, works great, and I've learned a new hook :-)

THANK YOU!

/chris

salah2020’s picture

this not hide the original node updating and creating new node..I THINK those messages created after this hook is execute

chandravilas’s picture

It is possible to alter or overwrite the success or failure message in a hook_entity_insert, hook_entity_update or at form submit handler level.

just use the following code.

\Drupal::messenger()->deleteAll();
\Drupal::messenger()->addStatus('ur custom message');

Note: This will work in D8.5+ version

ressa’s picture