Im using hybridauth to let users login from different social media websites ...
I send emails to some users with an link to edit a specific node (for example http://example.com/node/444/edit).
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->type == 'type' && other conditions){
    drupal_goto('link_to_hybridauth_login_page'); 
  }
}

Now I want that user to be automatically redirected to that edit node page (http://example.com/node/444/edit) after logged in via hybridauth ( I tried to add destination query inside drupal_goto but not working.)

how can I do this redirection ?

Thanks in advance.

Comments

vijaythummar’s picture

Redirection from hybridauth depends on hybridauth system.

you are passing destination query but check whether hybridauth is appending that query in URL or not?

Thanks,
Vijay Thummar

bol3ez’s picture

No, hybridauth it's not appending that query, because I tried to append the query inside hook_init().
drupal_goto('hybridauth_authentication_page', array('query' => array('destination' => '/node/'.arg(1).'/edit')))

these are the steps to clarify more this workflow :

  1. anonymos user recieve an email like this : http://mywebsite/node/5/edit
  2. when he click on that link, hook_init() check the url, get the nid from this url, check some conditions then redirect him to hybridauth page
  3. he choose one of the social media to login with
  4. a new popup open with new url (sth like http://mywebsite/hybridauth/window/...?destination=hybridauth_default_de...)

So only inside that hook_init() that I have access to the node object, otherwise if I use hybridauth rules to set a destination for example, I can't get the node edit url anymore.