Redirect anonymous user to login in custom module In a custom module, I'd like to redirect anonymous users to the login page. After a successful login the user should get to the page he intended to see.

I tried the following code. This gives me the login form, but the user is never sent to the destination page. Instead the standard user page gets displayed.

if (!$user-&gt;uid) {
    $dest = drupal_get_destination();
    drupal_goto('user/login', $dest['destination']);
}


Any ideas how to fix that?
Have you tried drupal_goto('user/login', array("query" =&gt; array("destination" =&gt; $dest['destination'])))?