I have a page with two links visible to people, but on clicking of either of two, user needs to log in to view, so in case user is not logged in, i am sending users to login page with drupal_goto('user'), i want that if the user clicked 1st link and is redirected to login page, after successful login, he should be redirected again to that 1st link i tried with this code but did not work,

$query = array('destination' => 'node/id');
  • @googletorp has provided an answer. If you are trying to create a link to the login form that would send the user back to the current page, see if drupal_get_destination works better.
    – AKS
    Commented Feb 2, 2016 at 20:50

1 Answer 1


You need to use drupal_goto the same way you use url.

So what you need to do is this:

$query = array('destination' => 'node/id');
drupal_goto('user', array('query' => $query));

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.