Skip navigation
Help

drupal_get_destination

6 common.inc drupal_get_destination()
7 common.inc drupal_get_destination()

Prepare a 'destination' URL query parameter for use in combination with drupal_goto().

Used to direct the user back to the referring page after completing a form. By default the current URL is returned. If a destination exists in the previous request, that destination is returned. As such, a destination can persist across multiple pages.

See also

drupal_goto()

Related topics

30 calls to drupal_get_destination()

File

drupal/includes/common.inc, line 505
Common functions that many Drupal modules will need to reference.

Code

function drupal_get_destination() {
  $destination = &drupal_static(__FUNCTION__);

  if (isset($destination)) {
    return $destination;
  }

  if (isset($_GET['destination'])) {
    $destination = array('destination' => $_GET['destination']);
  }
  else {
    $path = $_GET['q'];
    $query = drupal_http_build_query(drupal_get_query_parameters());
    if ($query != '') {
      $path .= '?' . $query;
    }
    $destination = array('destination' => $path);
  }
  return $destination;
}