Opened 3 years ago

Closed 3 years ago

#12282 closed enhancement (fixed)

Redirect option after registration and password recovery

Reported by: usermrpapa Owned by:
Priority: normal Milestone: 3.0
Component: Users Version: 2.9.2
Severity: normal Keywords: has-patch, tested
Cc: steve@…

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 3 years ago.
redirect-2.patch (2.8 KB) - added by usermrpapa 3 years ago.
12282.diff (3.1 KB) - added by nacin 3 years ago.
12282.2.diff (3.1 KB) - added by nacin 3 years ago.

Download all attachments as: .zip

Change History (19)

  • Cc steve@… added
  • Keywords needs-patch added

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

  • Keywords has-patch added; needs-patch removed

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

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

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'] : '' );

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...

comment:9 follow-up: ↓ 10   usermrpapa3 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.

nacin3 years ago

comment:10 in reply to: ↑ 9   nacin3 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.

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.

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.

nacin3 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.

yes, that seems to work nicely now!

  • 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.