I'm loving the thickbox login. A couple of usability requests:

- Once successfully logged in, keep the user on the page they were viewing, currently I'm being redirected to front.
- Provide a 'create new account' link for those without logins.

Comments

spooky69’s picture

As above. Interestingly, I note that this does redirect to the correct destination page when clicking a drupal generated login link, such as 'login to post a comment', but it loses the destination from a custom login that I am using:

print l("Login",'user/login' .drupal_get_destination());

The above just goes to front page using thickbox login, although the url shown when I hover over the login link generated by the above code does show the thickbox_login with the &destination= correctly appended to the url.

Any ideas?

spooky69’s picture

Status: Active » Closed (fixed)

Fixed - replacing ' with " seemed to sort it out.

Issue closed.

spooky69’s picture

Status: Closed (fixed) » Active

Ok, it did not fix it.

The issue seems to be that the login retains the destination url when using IE6 but does not retain the destination url when using Firefox or IE7.

Can anyone provide some advice or pointers as to why this could be happening?

wim leers’s picture

I have the same problem. Subscribing.

rkn-dupe’s picture

sub.

spooky69’s picture

Is there still no sign of a fix (or a comment perhaps) on this problem?

-- www.inventionmail.com --

frjo’s picture

Category: feature » support

Here are some example code for building your own login links.

global $user;
if ($user->uid) {
  print t('You are logged in as !name', array('!name' => theme('username', $user))) .' | '. l(t('log out'), 'logout');
}
else {
  print t('<a href="@login">Login</a>', array('@login' => url('user/login', drupal_get_destination())));
}
spooky69’s picture

Thanks for the response. I am currently using:

print l("Login", "user/login" .drupal_get_destination());

Shouldn't this work? Users are able to log in from the code I use, it just does not always seem to get the destination part. Is there any fundamental difference in the code you have listed above and the code I am using?

frjo’s picture

See her http://api.drupal.org/api/5/function/l how to use the l() function.

Something like this might work better.

print l(t('Login'), 'user/login', array(), drupal_get_destination());
spooky69’s picture

Thanks for the assistance and I will have a look at this. The odd thing is that it gets the destination when using IE6, but does not get the destination when using Firefox or IE7.......

esadot’s picture

Any new developments? I'd appreciate a robust solution.

TerrenceLP’s picture

try this out...

$(document).ready(function() { $("a[@href*='/user/login']").addClass('thickbox').each(function() { this.href = this.href.replace(/user\/login\??/, document.location.hostname + "/thickbox_login?height=220&width=250&") }) });
$(document).ready(function() { $("a[@href*='?q=user/login']").addClass('thickbox').each(function() { this.href = this.href.replace(/user\/login/, document.location.hostname + "/thickbox_login&height=220&width=250") }) });

Notice the addition of document.location.hostname +, this was it gets the current host name and the function works.

kulfi’s picture

Which file does this edit go in?

Anonymous’s picture

@ #13, the code is the output of thickbox.module with the addition of document.location.hostname +. Just edit the module, and add that extra bit.

It works for me now. I used #7's php code in my page.tpl.php, and #12's patch of the thickbox.module

palmergroup’s picture

I solved the "create new account", which was fairly easy. I've posted the walkthrough below. But first, my two cents. I really want this thickbox to work without having to go to the actual user/login or user/register page if there were an error. That means, if a user inputs an incorrect password, the thickbox remains and highlights the password field. Same goes for register.

Register link walkthrough.

Copy the thickbox_login.js and rename the new file to thickbox_register.js. Wherever you see the word "login" change it to "register". Then go into the thickbox.module and search for all words: "login". Just copy and paste each function (or block of code) that contains the "thickbox_login" and replace the "login" with "register". These steps are simple, however, the last one required a print_r($form) because I wasn't familiar with the e-mail array. Anyways, this is what I put for the form_alter (which is the last bit in the thickbox.module):

function thickbox_form_alter($form_id, &$form) {
  if ($form_id == 'user_login' && arg(0) == 'thickbox_login') {
    $form['#action'] = url('user/login', 'destination='. $_GET['destination']);
    $form['name']['#size'] = 25;
    $form['pass']['#size'] = 25;
  }
  if ($form_id == 'user_register' && arg(0) == 'thickbox_register') {
    $form['#action'] = url('user/register', 'destination='. $_GET['destination']);
    $form['name']['#size'] = 25;
    $form['mail']['#size'] = 25;
  }
}

You can see I included the part with the thickbox_login because you'll have to add your if statement inside this function.

Once that is done you'll need to go into the thickbox module options in the admin section and tick the "Enable for register links". Then i'd suggest going back into your thickbox_register.js and changing the height to 250. Should be good to go after that.

drupalina’s picture

Re #15 , cronin...
This is simply great! But it's still not 100% user-friendly.
I'm wondering if it would be possible to display the standard 3-tabbed view inside Thickbox -- i.e. "Create New Account" "Forgot Password?" and "Login" -- ALL in the same Thickbox ???

I'm also wondering which one is the robust working solution for making sure that after logging in the user remains on the same page he was seeing, rather than being redirected to the front-page??? I mean that's the whole point of thickbox - so that the user remains on the same page.

ekrispin’s picture

Subscribing...

I see that this issue is open for almost a year... I understand that there is no one seriously maintaining the module... I wonder if there is any alternative...

frjo’s picture

This module is maintained. The feature discussed here is not one I need but if someone send in a good patch that others test to make sure it works well I will commit it.

aerodog’s picture

Hey folks,

Honestly this thread confused me. There was this php script which makes sense for page.tpl, a "print l" line I'm not sure where we ought to place, a document.location.hostname + couple of lines which should, i believe, be in thickbox_login.js but someone claims is a fix for thickbox.module, and even that seems to make formerly "http://www.example.com/thickbox..." links into "http://www.example.com/www.example.com/thickbox..." links.

When I added the document.location.hostname + stuff with the backslash before 'thickbox', all I get is a thickbox that's blank with no forms printed. I actually am trying to get this to work for registration (not for login, though the same rules should apply). What can I be doing wrong?

Here's what I want to do to be more precise. I want a thickbox registration where if the registration goes wrong, I stay within the thickbox, and if registration goes right, I return to my original page.

Any help is appreciated to make clear the suggestions above. I've been tinkering around with this for a while now to no avail! All help is appreciated.

ekrispin’s picture

Title: Thickbox Login » create new account and request password links

Solution is very simple (I assumed it would be somehow difficult as this issue is open for 16 months without even a clue given about how to solve it...)

Oh well, here is what you have to do:

In function thickbox_login() in thickbox.module after print drupal_get_form('user_login'); add the following lines:

$items[] = l(t('Join now!'), 'user/register', array('title' => t('Create a new user account.')));
$items[] = l(t('Request new password'), 'user/password', array('title' => t('Request new password via e-mail.')));
print "<br />". theme('item_list', $items);

Also , change the hight of the window in thickbox_login.js to 240 to avoid scrolling.

HS’s picture

thanks ekrispin! Bless ya!

Parkes Design’s picture

thanks ekrispin! Much Appreciated... I'm surprised they haven't made this standard yet.

This also does the trick

print drupal_get_form('user_login_block');

frjo’s picture

Version: master » 6.x-1.x-dev

I hace just added a Thickbox setting to 6-dev for what login form to use, user_login, user_login_block or custom. It defaults to user_login.

wim leers’s picture

Status: Active » Closed (fixed)
open social’s picture

- Once successfully logged in, keep the user on the page they were viewing, currently I'm being redirected to front.

This worked for me:

<?php
print l(t('Login'), 'user/login', array('query' => drupal_get_destination()));
?>