When logging in from a block (that is: not from the login page), the login fails and I'm redirected to the login page, where logging in succeeds.
It doesn't give any warnings about user authentication (and it shouldn't because I give the right credentials).
Is there a mistake in the form_id? what's wrong? Has anyone else got the same problem?

minor mistake to be fixed for the sake of clean code: the module doesn't have a closing tag for php ( ?> )

Comments

z.stolar’s picture

I partialy solved the problem, but I still don't get it...

the original code:
<?
function login_destination_get_destination() {
// customize the path as desired.
$path = 'archive';
return url('user', "destination=$path");
}
?>

What I did was to change the <? return url('user', "destination=$path"); ?> to <? return url('main', "destination=$path"); ?> where 'main' is an alias for my main node.

Why does it work?!

z.stolar’s picture

Ooops... code was ommited...
So... the original was:

<?php
function login_destination_get_destination() {
  // customize the path as desired. 
  $path = 'archive';
  return url('user', "destination=$path");
}
?>

And I changed it to be:
<?php return url('main', "destination=$path"); ?>
where 'main' is an alias for my main node.

z.stolar’s picture

Status: Active » Needs review

Sometimes it's nice to talk to yourself. After all, it's not often that you get to talk to someone as inteligent as you...

I beleive I found the problem with this function:
While the original line was: return url('user', "destination=$path"); ,
it should actualy be: return url($_GET['q'], "destination=$path");

Am I right?

calebgilbert’s picture

If anyone has any problems with this module they can just hardcode the url instead of using the $path varialble (which in retrospect seems like it might be unnecessary).

For example:

function login_destination_get_destination() {
  // customize the path as desired. 
  $path = 'myproject';
  return url($_GET['q'], "destination=$path");
}

turns into:

function login_destination_get_destination() {
  // customize the path as desired. 

  return url($_GET['q'], "destination=whatever_url_youwant");
}
ardas’s picture

Greetings,

I became a maintainer of this module and am going to improve it. Please download a new 4.7 release in a day and try if this defect still exists. I changed redirection logic and it fixes several problems.

If login doesn't work from a block it may be another big core bug which was fixed in Drupal recently. Please, try to login without login_destination and find out will it work or not.

>> minor mistake to be fixed for the sake of clean code: the module doesn't have a closing tag for php ( ?> )
It is not a mistake - it is a Drupal coding standard. It is suggested to ommit PHP closing tag.

Thanks.

ardas’s picture

Assigned: Unassigned » ardas
Status: Needs review » Fixed

Fixed for now. Please, try the new version.

Anonymous’s picture

Status: Fixed » Closed (fixed)