8.5.x common.inc drupal_get_destination()
8.0.x common.inc drupal_get_destination()
8.1.x common.inc drupal_get_destination()
8.2.x common.inc drupal_get_destination()
8.3.x common.inc drupal_get_destination()
8.4.x common.inc drupal_get_destination()
8.6.x common.inc drupal_get_destination()
4.6.x common.inc drupal_get_destination()
4.7.x common.inc drupal_get_destination()
5.x common.inc drupal_get_destination()
6.x common.inc drupal_get_destination()
7.x common.inc drupal_get_destination()

Prepare a destination query string 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()

8 calls to drupal_get_destination()
comment_admin_overview in modules/comment/comment.module
node_admin_nodes in modules/node/node.module
node_page_edit in modules/node/node.module
Menu callback; presents the node editing form, or redirects to delete confirmation.
path_overview in modules/path/path.module
Return a listing of all defined URL aliases.
statistics_top_visitors in modules/statistics/statistics.module
Menu callback; presents the "top visitors" page.

... See full list

File

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

Code

function drupal_get_destination() {
  if (isset($_REQUEST['destination'])) {
    return 'destination=' . urlencode($_REQUEST['destination']);
  }
  else {

    // Use $_GET here to retrieve the original path in source form.
    $path = isset($_GET['q']) ? $_GET['q'] : '';
    $query = drupal_query_string_encode($_GET, array(
      'q',
    ));
    if ($query != '') {
      $path .= '?' . $query;
    }
    return 'destination=' . urlencode($path);
  }
}