2

When the requested page is /user/login, users should be redirected to /mylogin.

I know this is possible with hook_init() or hook_boot(). Can someone explain how this can be achieved, exactly?

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');
  }
}
1
  • 4
    Using drupal_goto() in hook_init() often leads to issues. I'd rather not do it.
    – Countzero
    Jun 22, 2012 at 11:14

Your Answer

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