- 🇩🇰Denmark ressa Copenhagen
This is a great idea! It would be awesome to be able to alter the text at some point, and hope it's ok that I reopen the issue?
- 🇩🇰Denmark ressa Copenhagen
As a workaround until (or if) this lands, here's one method to tweak the message, from a MR for Simplenews:
use Drupal\Core\Entity\EntityForm; /** * Implements hook_form_alter(). * * Adds link to preview and send page above a newsletter. */ function simplenews_form_alter(&$form, &$form_state, $form_id) { $forms = [ 'node_simplenews_issue_form', 'node_simplenews_issue_edit_form', ]; $admin_or_send_rights = (\Drupal::currentUser()->hasPermission('administer newsletters') || \Drupal::currentUser()->hasPermission('send newsletter')); if (in_array($form_id, $forms) && $admin_or_send_rights) { // Adding custom callback to customize status message. $form['actions']['submit']['#submit'][] = '_post_node_save_callback'; } } /** * Custom callback to customize status message. */ function _post_node_save_callback($form, &$form_state) { $form_object = $form_state->getFormObject(); if ($form_object instanceof EntityForm) { $node = $form_object->getEntity(); $node_id = $node->id(); \Drupal::messenger()->addStatus(t('Preview or send it via the <a href="/node/' . $node_id .'/simplenews">Newsletter</a> tab, administer under <a href="/admin/content/simplenews">Newsletter issues</a>.')); } }
Based on the great blog post Customize/override the “node has been created/updated” status message on Drupal 9 by Barbara Bombachini → .