2

I'm having a Simplenews newsletter template with a link guiding newsletter readers to a intranet site with more news.

<?php print l('hier.', 'node/' . $build['#node']->nid, array('absolute' => TRUE)); ?>

My problem now is, that if the user is not logged in, that link only brings him to the login site, where he is then stucked.

What would I have to do or what function would help me to somehow provide a link that redirects the not logged in user to the proper aim after logging in, and which would not affect the already logged in user?

1
  • nit3ch's correct answer putted on the questioned snippet: <?php print l('hier.', 'user/login', array('query' => array( 'destination' => 'node/' . $build['#node']->nid))); ?>
    – leymannx
    Nov 15, 2013 at 18:40

1 Answer 1

5

You can add a additional destination parameter to the function.

<?php
print l(t('Title'), 'url', array('query' => array('destination' => 'destination_url')))
?> 

This will create :

<a href="url?destination=destination_url">Title</a>

Hope it helps.

2
  • or just to previous page: print l(t('Title'), 'url', array('query' => drupal_get_destination()));
    – malcolm
    Apr 22, 2013 at 11:17
  • @nit3ech - Is destination also making the link automatically absolute? Seems to...
    – leymannx
    Nov 15, 2013 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.