Same name and namespace in other branches
  1. 4.7.x includes/common.inc \drupal_get_destination()
  2. 5.x includes/common.inc \drupal_get_destination()
  3. 6.x includes/common.inc \drupal_get_destination()
  4. 7.x includes/common.inc \drupal_get_destination()
  5. 8.9.x core/includes/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.

See also

drupal_goto()

5 calls to drupal_get_destination()
comment_admin_overview in modules/comment.module
Menu callback; present an administrative comment listing.
node_admin_nodes in modules/node.module
Generate the content administration overview.
path_overview in modules/path.module
Return a listing of all defined URL aliases.
user_admin_account in modules/user.module
user_login in modules/user.module

File

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

Code

function drupal_get_destination() {
  $destination[] = $_GET['q'];
  $params = array(
    'from',
    'sort',
    'order',
  );
  foreach ($params as $param) {
    if (isset($_GET[$param])) {
      $destination[] = "{$param}=" . $_GET[$param];
    }
  }
  return 'destination=' . urlencode(implode('&', $destination));
}