Gating/Redirecting anonymous user back to an origin page after logging in/registration I have a use case where I need to redirect a user visiting a page, let's say sprockets/order when a user clicks on an "order" link. We take them to a page with a login field (not user/login, but something with that form). Once they log in, we need to redirect them to that page, or for that matter, any origin page they click from to the login page. 

I've looked into a couple of modules, right now Login Destination is the one i'm experimenting with, with no real success, even when its routing is configured to fire from this origin page. I'll keep experimenting with it, but I can't imagine its the only option at hand.

The question ultimately is, with the logic below, is there an approach I can take with how I send users to this specialized login page, and have them return to the origin?

The logic I have for this is as follows:

/**
 * Implements hook_menu()
 */
function hook_sprocket_menu() {
  $items['order/%order_id'] = array(
    "title" =&gt; t("Order Sprocket"),
    "page callback" =&gt; "example_order_sprocket",
    "page arguments" =&gt; array(1),
    'access arguments' =&gt; array('interact with orders'),
    "type" =&gt; MENU_LOCAL_TASK,
  );

  return $items;
}

/**
 * Routes the order call based on click
 */
function example_order_sprocket($orderid) {
  global $user;

  if(user_is_anonymous()) {
    drupal_goto("custom/user/login"); //The custom login/reg page
  } else {
    //Continue with Order logic here
  }
}
You can have destination parameter in url. Something like below.

drupal_goto('custom/user/login', array('query' =&gt; array('destination' =&gt; current_path())));