Redirect to a specific page in ajax callback How can I redirect to a specific page in an ajax callback using Drupal 7, I've already tested this method:

function my_ajax_callback($form, &amp;$form_state) {
  if (!user_is_anonymous()) {
    return $form['my_fieldset'];
  }
  else {
    drupal_goto('login');
  }
}


but that code doesn't redirect to /login when current user is anonymous.
I had the same problem. You should try this:

ctools_include('ajax'); 
ctools_add_js('ajax-responder');
$commands[] = ctools_ajax_command_redirect('login');
return array('#type' =&gt; 'ajax', '#commands' =&gt; $commands);