Destination: Logged In
I got a report recently that people were annoyed by the fact that when you use the login link at the upper right of the site, you get pushed off to your account page. Readers don't want to go their dumb ol' account page; they want to stay on the page they were on! How else can they make the witty comment they had in mind when they decided to log in in the first place??
Drupal (the engine behind DNN) is supposed to do this by default - direct users back to whatever they were looking at. So why wasn't it working? Well, because I broke it a long time ago and never realized it. Well, ok, I didn't break it. But I altered it to display the login form in the little modal window that comes up rather than redirect to a login form on a different page. And my custom login form wasn't passing this critical piece of data about what it should do after successful login.
Well, duh, says I, once I saw what I had done. For you nerds out there who get into things like writing Drupal modules, here's what I added to my form alter hook to fix the problem:
function dnn_form_alter(&$form, $form_state, $form_id)
{
// ... other stuff that this hook is already used for ...
// Add destination param to login form action
if ($form_id == 'user_login' && !isset($_GET['destination'])) {
$form['#action'] .= (FALSE === strpos($form['#action'], '?')) ? '?' : '&';
$form['#action'] .= 'destination='.$_GET['q'];
}
}
Viola. The current path is always passed into the form action, telling Drupal where you want to go after you log in. And if you prefer to go to your account page every time rather than stay on the page you were reading...well, tough. You're weird.

