0

I have $u variable which stores the path in hook user login to redirect users to the page.

drupal_goto($u);

I am not being redirected to the page- path $u. drupal_goto not working. I have tried everything increased te weight of the module,even tried with $_GET['destination'].

  • 1
    Cleared the Cache? I guess you have written the hook function name correctly. Did you try a fixed URL? like 'user/edit'? – Potney Switters Oct 22 '13 at 9:45
  • Please share your code also. – Jayendra Kainthola Oct 22 '13 at 9:56
1

Instead of using drupal_goto(), try passing the path in $edit['redirect'] in hook_user_login as below:

<?php
/** 
 * Implements hook_user_login().
 */
function hook_user_login(&$edit, $account) {
  // To check if the form is not the user reset form.
  if (!isset($_POST['form_id']) || $_POST['form_id'] != 'user_pass_reset') {
    $GLOBALS['destination'] = 'PATH_YOU_WANT_TO_REDIRECT';
  }
}
?>
  • Tried with $edit['redirect'] also. did not work. – neetu morwani Oct 22 '13 at 9:51
  • 1
    @neetumorwani can you once try this: $GLOBALS['destination'] = 'PATH_YOU_WANT_TO_REDIRECT';. Don't forget to clear the cache after appplying the changes – Ankit Agrawal Oct 22 '13 at 9:54

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.