hybridauth redirection to an emailed link after success login Im using hybridauth to let users login from different social media websites ...
I send emails manually to some users with an link to edit specific nodes (for example http://example.com/node/444/edit?parma1=val1&amp;param2=val2).
At that moment the user is automatically redirected to a page to choose a social media he want to login with.
Im using hook_init for this :

function MYMODULE_init(){
  if($node-&gt;type == 'type' &amp;&amp; other conditions){
    drupal_goto('link_to_hybridauth_login_page'); 
  }
}


Now I want that user to be automatically redirected to that link sent via email after success login via hybridauth ( I tried to add destination query inside drupal_goto but not working.)

how can I do this redirection ?

Thanks in advance.
How did you try to add the 'destination' query? It should be something like this:

$query_array = array('param1' =&gt; 'value1', 'destination' =&gt; 'original_path');
$options = array(
  'query' =&gt; query_array,
);
drupal_goto('link_to_hybridauth_login_page', $options);


Basically, it's important that the destination is passed as part of the $options['query'].

If that doesn't work, try and add your own hook_user_login(), to pick up the 'destination' (or whatever parameter you want to use for the original URL, and redirect the user accordingly). Like:

if (isset($_GET['destination'])) {
  drupal_goto($_GET['destination']);
}


You can see an example implementation of hook_user_login in the user_homepage module code: http://cgit.drupalcode.org/user_homepage/tree/user_homepage.module?id=6803e00

Hope this helps with your problem.

EDIT: The hook_user_login() is meant to be something additional to the hook_init() logic you were trying, but not to replace it. Thought I'd just clarify that =).

EDIT 2: Ok, So if I'm getting the problem right, you need to get not only the 'node/xxx/edit' part of the URL, which you have already sorted (right?) but you need to also get all the params of the incoming URL.

Basically, you need to use drupal_get_query_parameters() for that. So you could assemble the $options array like this:

  $current_query_params = drupal_get_query_parameters();
  // Pick up URL and treat params as you need, and prepare query array with 
  // the 'destination' desired, assembled with data from $current_query_params.
  $new_query_array = array();  
  $options = array(
    'query' =&gt; $new_query_array,
  );


Hope I'm getting it right now. The linked drupal code from user_homepage uses these functions for a very similar scenario. Look at user_homepage_build_homepage_path_from_request() and user_homepage_user_login() functions.