3

I wanted to override/change the text message that appears while sending Drupal mail.

This is the text "Unable to send e-mail. Please contact the site administrator if the problem persists."

What are the ways to change this message into my own custom message ?

1
  • There is no way to change it via some alter function but you can try to override this message via theme function theme_status_messages
    – Eugene
    Commented Sep 2, 2015 at 10:33

2 Answers 2

2

You can use String Overrides modules for overriding any string that passed through t().

Here are some details about this module from its project page:

Provides a quick and easy way to replace any text on the site.

Features:

  • Easily replace anything that's passed through t()
  • Locale support, allowing you to override strings in any language
  • Ability to import/export *.po files, for easy migration from the Locale module
  • Note that this is not a replacement to Locale as having thousands of overrides can cause more pain then benefit. Use this only if you need a few easy text changes.
1

Write some custom code in which you use a variation of the approach as explained in Hook into and Preprocess Drupal Messages? Here is a quote from it:

The following example hides all error/warning messages from anonymous users and user's who don't have the 'administer nodes' permission. You can easily add your own conditions to filter out which message types should be displayed to who.

function mytheme_status_messages ($display = NULL) {

  $output = '';
  foreach (drupal_get_messages($display) as $type => $messages) {

    // skip all error/warning messages for anonymous users
    if (!user_is_logged_in() && ($type == "error" || $type == "warning")) { continue; }

    // skip error/warning messages for users who don't have the 'administer nodes' permission
    else if (!user_access('administer nodes') && ($type == "error" || $type == "warning")) { continue; }

    ...
3
  • 1
    Nice. What about fine grain filtering, by source? I mean in the reports messages can be filtered by eg php or modulename or whatever the developer did setup in its messages implementation. ..maybe I could just dpm $messages...?! And does this override UI setup please?
    – Kojo
    Commented Sep 2, 2015 at 11:47
  • 1
    Merci (thank you) for the feedback @Kojo ... I think I might not fully understand your "by source" suggestion. But it's similar to some of the things I've been thinking of before also. Something like "For any out-of-the-box message that I think is not clear enough, there should be an easy way to 'customise' such message". It's like adapting the CSS of a theme, to fit your own requirements. Maybe this is worth a new question on Drupal.SE? Or even a new module like "custom messages"? Commented Sep 2, 2015 at 11:56
  • 1
    By source I meant category. which module sent it...I'll check it out. Merci!
    – Kojo
    Commented Sep 2, 2015 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.