Redirect user after registration I am trying to redirect new users after registration depending on values saved in $_SESSION. I use ajax for registration form submission and hook_user_insert fro redirect

function MYMODULE_user_insert(&amp;$edit, $account, $category){
global $user;
if(isset($_SESSION['VAR']) &amp;&amp; !$user-&gt;uid){
    drupal_goto('path/to/somewhere');

}


Once form is submitted I receive alert AJAX HTTP request terminated abnormally and page html code. What should I change to make redirect working?
You should alter the register form and set new redirect value.

function MYMODULE_user_register_form($form, &amp;$form_state) {
  $form_state['redirect'] = 'path/to/somewhere';
}