2

If the user requests www.mysite.com/user/login he should be redirected to www.mysite.com/mylogin. I know this is possible with hook_init or hook_boot, can some one explain how this can be achieved.

Thanks

1 Answer 1

6
/**
 * Implements hook_init().
 */
function mymodule_init() {
  global $base_url;
  if (user_is_anonymous() && arg(0) == 'user') {
    drupal_goto($base_url . 'mylogin');
  }
}
3
  • Thanks for your reply. My problem is i am using Ajax register/login module to display the login and registration form in overlay effect. When i click this modules block link i get these form in overlay effect. But when i visit /user/register and the /user/login i dont get them in overlay effect. So i thought of redirecting the user to the "ajax_register/login/nojs" (brings overlay effect) if a request. But it throws me "has resulted in too many redirects"
    – user4081
    Jun 22, 2012 at 8:02
  • 3
    Using drupal_goto in an init hook often leads to that kind of issues. I'd rather not do it.
    – Countzero
    Jun 22, 2012 at 11:14
  • Is there any way to solve this?
    – Kiran Tej
    Nov 13, 2013 at 3:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.