0

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');
drupal_goto('user',$query);
  • @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. – AyeshK Feb 2 '16 at 20:50
2

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));
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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