5

How can I change, or customize, the message shown to the user after registration in Drupal 7?

Further instructions have been sent to your e-mail address.

I tried the following code, but it didn't work for me.

function mymodule_message_alter(&$messages) {
  switch($messages->messages['status'][0]) {
    case 'Further instructions have been sent to your e-mail address.':
      $messages->messages['status'][0] = t('Your reset password instructions have been sent to your e-mail address. Please check your email and follow the instructions</p>');
    break;
  }

  // Disabling / Suppress all messages on a page and only display one Message
  if(arg(0) =='your-custom-page') {
    if($messages->messages['error']) {
      unset($messages->messages['error']);
      $messages->messages['error'][0] = t('This is my custom message to replace 10 system messages :) ');
    }
  }
  return $messages;
}

1 Answer 1

6

It might be overkill for a single message but the String Overrides module would work.

It includes a UI for quickly adding string replacements for anything that is passed through the t() function, which includes the message that you're trying to replace.

4
  • String overrides wont work, as it uses the same text as a password recovery notification.
    – user6439
    Commented Mar 27, 2012 at 14:12
  • @user6439 Not true, String Overrides works perfectly for this. The only place that specific message is set in core is in user_pass_submit(), with this line: drupal_set_message(t('Further instructions have been sent to your e-mail address.'));. As you can see, that has been passed through the t() function, so will work correctly with String Overrides.
    – Clive
    Commented Mar 27, 2012 at 14:22
  • 2
    It should also be noted the logintoboggan module also changes/sets messages after registration. For example in logintoboggan.module you can see messages such as $message = t('Thank you for applying for an account. Your account is currently pending approval by the site administrator.<br />Once it has been approved, you will receive an e-mail containing further instructions.'); and $message = t('A validation e-mail has been sent to your e-mail address. In order to gain full access to the site, you will need to follow the instructions in that message.'); Commented Apr 6, 2014 at 14:24
  • I believe that for the string overrides module to work you need put the whole target whole message string into string overrides, not just a part of it. For example if the string you are trying to replace is over two lines you would need to include the <br /> tag. e.g. 'Thank you for applying for an account. Your account is currently pending approval by the site administrator.<br />Once it has been approved, you will receive an e-mail containing further instructions. was replaced correctly. Commented Apr 6, 2014 at 14:30

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.