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(&$path, $original_path,
$path_language) {
$argument = explode('/', $path);
if (!user_is_logged_in() && isset($argument[0]) && $argument[0] == 'user' && isset($argument[2]) && $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.
How can I achieve this.