How to add destination parameter in hook url_inbound_alter Hi I have used  hook_url_inbound_alter to alter the URL. When I access user/%/order anonymously it should redirect ti user/login. I have used below code

 function module_url_inbound_alter(&amp;$path, $original_path,
 $path_language) {   
  $argument = explode('/', $path);  
  if (!user_is_logged_in() &amp;&amp; isset($argument[0]) &amp;&amp; $argument[0] == 'user' &amp;&amp; isset($argument[2]) &amp;&amp; $argument[2] == 'orders') {
      $path = 'user/login';

   } 
}


It redirects the user to login page but my question is how to add destination parameter. Above code redirects localhost/drupal/user/login
but I want to add destination paramater such as localhost/drupal/user/login?destination=user/1/order

When I tried to  add the desination variable in $path variable 


  $path = '/user/login?destination=user/1/order;


I am getting the url like this 


  http://localhost/drupal/user/login%3Fdestination%3Duser/1/order


Instead it should be like this.


  http://dt.drop/user/login?destination=user/1/order


How can I achieve this.
For your particular problem (redirect an anonymous user to user/login), it can be better to redirect on form submit. So, on hook form_submit() you check whether user_is_logged_in(), if not drupal_goto('user/login').