Using 'drupal_get_destination()' with a l() link

This Comment will be submitted for moderation and will not be accessible to other users until it has been approved.


23 points

Hi, I'm trying to create a login link that returns the user to their previous page once logged in. The link looks something like:

"l(t('login'), 'user/login?'.drupal_get_destination() ..."

Which correctly shows as "user/login?destination=recipe" in the source, but turns into
"user/login%3Fdestination%3Drecipe" 

once on the login page, and doesn't work.

What am I doing wrong?



-9 points

Use this. The key is in using $base_url with the link.

global $base_url;
  $linkform = array(
    '#type' => 'markup',
    '#value' => l("Click here to ship to International", $base_url."/set_country/840?".drupal_get_destination()),
 );

Anonymous's picture
Created by Anonymous

Post Comment

  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.