Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a page which makes certain verifications and needs to redirect the user in certain cases. In those cases, I want the destination page to show a message, but I can't get it to work. Here is my code:

if ($userNeedsToBeRedirected) {
  drupal_set_message(null, "You've been redirected because ...");

The redirection works, but the message doesn't appear. What can I do?

Note: I also tried the following:

if ($userNeedsToBeRedirected) {
  drupal_goto('destination', array(
    'query' => array(
      'message' => "You've been redirected because ..."

and in the destination page:

if (isset($_GET['message'])) {
  drupal_set_message(null, $_GET['message']);

but is doesn't work either because (I believe) drupal_set_message is being called too late the the page creation process.

share|improve this question
up vote 3 down vote accepted

You are setting a NULL message in drupal_set_message, the correct syntax would be:

if ($userNeedsToBeRedirected) {
  drupal_set_message("You've been redirected because ...");

The second drupal_set_message $type parameter is for the message type:

  • 'status'
  • 'warning'
  • 'error'
share|improve this answer
Thanks, I was using the syntax for form messages.. – Shawn Jan 10 '13 at 21:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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