Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#12282 closed enhancement (fixed)

Redirect option after registration and password recovery

Reported by: usermrpapa's profile usermrpapa Owned by:
Milestone: 3.0 Priority: normal
Severity: normal Version: 2.9.2
Component: Users Keywords: has-patch, tested
Focuses: Cc:

Description

we get a lot of user requests (and would be handy indeed) for a redirect after a registration or password recovery form as an option to reloading the login page. This would be similar to the filter or redirect ability on the login page itself.

Attachments (4)

redirect.patch (1.2 KB) - added by usermrpapa 15 years ago.
redirect-2.patch (2.8 KB) - added by usermrpapa 15 years ago.
12282.diff (3.1 KB) - added by nacin 15 years ago.
12282.2.diff (3.1 KB) - added by nacin 15 years ago.

Download all attachments as: .zip

Change History (19)

#1 @usermrpapa
15 years ago

  • Cc steve@… added

#2 @nacin
15 years ago

  • Keywords needs-patch added

#3 @usermrpapa
15 years ago

patch for allowing redirection instead of going to wp-login.php on password reset and registration... obviously the wp messages wont display, that would be up to the redirection receiver...

patch from R13356

#4 @usermrpapa
15 years ago

  • Keywords has-patch added; needs-patch removed

#5 @usermrpapa
15 years ago

actually, I dont think thats right... back in bit...

#6 @usermrpapa
15 years ago

alright lets try redirect-2.patch. works, but open to suggestions.

#7 @nacin
15 years ago

What are you trying to do here:

if ( isset( $_REQUEST['redirect_to'] ) ) { 
   $redirect_to = $_REQUEST['redirect_to']; 
} else { 
   $redirect_to = ''; 
} 
$redirect_to = apply_filters('registration_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''); 

Looks like that should all just be:

$redirect_to = apply_filters( 'registration_redirect', isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '' );

#8 @usermrpapa
15 years ago

well, its really just trying to mimic the redirection allowed on the login form. I want to be able to redirect on registration or lost password forms rather than reloading the wp-login.php file. also wanted to allow filtering of the redirect.

it seemed a bit convoluted to me, but tried to mimic the login form redirection...

#9 follow-up: @usermrpapa
15 years ago

  • Keywords tested added

nacin, does that make sense? better way? as I said, this works for me, but may not be the most elegant solution.

@nacin
15 years ago

#10 in reply to: ↑ 9 @nacin
15 years ago

Replying to usermrpapa:

nacin, does that make sense? better way? as I said, this works for me, but may not be the most elegant solution.

Check to see how the attached patch works.

#11 @usermrpapa
15 years ago

No, that doesnt work - at least not like it does for login redirection.

Thats because when the form (register or lost password) is loaded, the hidden input redirect_to will always be empty, unless the redirect filter is used. Any $_REQUESTredirect_to? (ie query arg on the url) is ignored. The login redirect checks for the $_REQUEST before the filters and sets $redirect_to to the $_REQUEST if its there. That way a redirection can be accomplished without using a filter. Thats what some of the stuff you removed from my patch (yours looks cleaner, btw) did.

Now, since there is a filter applied, this can be made to work, just pointing out that it functions a bit differently than the standard login redirection. On login, you can redirect simply with the url. With this patch, you cannot for registration or lost password.

#12 @nacin
15 years ago

Sorry,

$redirect_to = apply_filters( 'registration_redirect', isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '' ); 

Should be:

$redirect_to = apply_filters( 'registration_redirect', isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '' ); 

Patch refreshed in a moment.

@nacin
15 years ago

#13 @nacin
15 years ago

My comment clearly didn't make sense thanks to copy-paste. The part that needed to change is the removal of the extraneous $redirect_to argument passed to the filter.

#14 @usermrpapa
15 years ago

yes, that seems to work nicely now!

#15 @nacin
15 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [13465]) Add redirect_to and associated filters to registration and password recovery. fixes #12282

Note: See TracTickets for help on using tickets.