I am using instant login after registration and I want the user to get redirected to the contents of ?destination after registering, so I added this two liner.

If you want the default login form to add ?destination to the registration button, add this to your hook_menu in the !$may_cache section:

if ($_GET['destination']) {
global $_menu;
$_menu['items'][$_menu['path index']['user/register']]['query'] = 'destination='. $_GET['destination'];
}

Comments

hunmonk’s picture

i'm not so sure i like this. it seems like it could lead to unintended behavior.

also, can you explain a clear use case for this?

JacobSingh’s picture

Sure, on most websites, when a user wants to do something they cannot do as an anonymous user, the site offers them the ability to login or register. If they login, they should go back to what they are doing. We shouldn't send them somewhere else and confuse them. The point is for them to get where they want to go. If they register, we want the same behavior. Registration should not impede what a user was originally intending to do. Of course there are plenty of examples out there, just about any e-commerce site or social networking site (except myspace - which is not IMO a usability case study) :)

Hope that helps,
Jacob

hunmonk’s picture

Status: Needs review » Closed (works as designed)

if immediate login is enabled, and i use the url http://example.com/user/register?destination=foo, then i'm already redirected to http://example.com/foo after registration, because of the way FAPI and drupal_goto() work.

i see no necessary change here.

JacobSingh’s picture

Try it, didn't work for me.

hunmonk’s picture

then i'm assuming that you're either using the incorrect URL, or there's a setting messed up somewhere. works as advertised on my local dev box.

JacobSingh’s picture

Yes you are right, and I am crazy, and I have to quit working. :)

Sorry to bother you, it's time for a beer.

wwwoliondorcom’s picture

Hi,

Have you found a reliable solution to redirect to previous page ?

Thanks for help.

halloffame’s picture

After over 3 years still no solution?

hunmonk’s picture

@evilgenius: check the status of the issue -- there is no problem to begin with.

khu’s picture

Hi,

Could you elaborate upon where I can put the lines of code you mentioned in the issue summary?

Do I alter the core module or do I put the codes in a hook_menu function of a custom module?

I am using D7.

Thank you for the help!

sszawlim’s picture

Hello,
how do i make this work in drupal 6?

I want to send user back to the previous page, after they register the account.

Thanks,
Sam