Help with Email Links to Protected Articles

Events happening in the community are now at Drupal community events on www.drupal.org.
ericag's picture

Hello out there! I am having an issue that I am hoping someone out there has pointers for resolving. We have an email newsletter which we send to encourage customers to visit our site. In the email, we provide article teasers and links to the articles allowing people to "read more". The articles are protected such that people have to be a member to read them. The problem we are encountering is that customers click the link, login, and then they are routed to the home page rather than to the article.

This is happening because we have a module called login_destination installed and we have it set up to send people to the home page upon logging in rather than to the really confusing account page.

Wondering if anyone knows of a way that we can make login_destination do what we want when people log in normally but have a different behavior when people are logging in via an email click.

Thank you for any thoughts you might have on this crazy question!

Comments

One approach

arthurf's picture

drupal_get_destination() is what you need, however, this may not play so nice with login_destination. You could do something like this:

<?php
 
function mymodule_form_alter($form_id, &$form) {
     if (
$form_id == 'user_login') {
       
$form['#action'] = url('user/login', drupal_get_destination());
     }
  }
?>

This catches the user/login form and appends the original destination (ie: the path that you gave the user) to the url that the form submits. This then redirects the user once they pass the user/login form.

The problem is that this will over ride your login_destination settings. You could do a few things to get around this - put a indicator in your urls that these should not redirect to the home page- something like http://blah.bah/my/page?redirect=true. Then in the function above, just add $_GET['redirect'] to the if statement. You could also do this based on the path of the page that the user is looking for, but that gets a bit more mess and is potentially brittal because it requires consistent urls.

a.


http://24b6.net

Customize Profile Page?

ericag's picture

Sorry not to reply sooner... I don't think I have my settings for this forum quite right yet.

Thank you very much for this good idea and for explaining possible problems and workarounds!

To take this in a slightly different direction... is there a way to customize the profile page (to omit some of the registration info we collect and to have a more friendly layout)? I'm thinking that if I did that, I might not need login_destination at all which would also solve my problem. Is that maybe a theming issue -- I'm not even sure what part of drupal makes this page look the way it does.

Also, wondering what other people do? Do other VT drupalers out there use the default of sending logged in folks to the profile page first or do you override this behavior? Why? Curious if I'm missing out on some important benefit of this default.

Erica

Vermont

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: