Make WordPress Core

Opened 11 years ago

Closed 10 years ago

#27617 closed enhancement (fixed)

Introduce a `logout_redirect` filter

Reported by: johnbillion's profile johnbillion Owned by: johnbillion's profile johnbillion
Milestone: 4.2 Priority: normal
Severity: minor Version: 2.6
Component: Login and Registration Keywords: has-patch
Focuses: Cc:

Description

The login_redirect filter is applied to the redirect URL when a user logs in. There is no corresponding filter applied to the redirect URL when a user logs out.

Attachments (2)

27617.patch (756 bytes) - added by johnbillion 11 years ago.
27617.2.patch (1.1 KB) - added by SergeyBiryukov 10 years ago.

Download all attachments as: .zip

Change History (9)

@johnbillion
11 years ago

#1 @johnbillion
11 years ago

  • Keywords has-patch added; needs-patch removed

Thoughts?

#2 @juliobox
11 years ago

Why not, but you already can do this, even if it's a little tricky:

add_filter( 'wp_redirect', 'logout_redirect_filter' );
function logout_redirect_filter( $location ) {
	if ( isset( $_REQUEST['action'], $_REQUEST['redirect_to'] ) && 'logout' == $_REQUEST['action'] ) {
		$location = home_url( '/my-own-url/' );
	}
	return $location;
}

Thoughts?

#3 @johnbillion
10 years ago

  • Milestone changed from Awaiting Review to 4.2

#4 @DrewAPicture
10 years ago

I don't really have a problem with this, though I wonder if perhaps we should pass both the original value of redirect_to as well as the derived fallback, just as we do in the login_redirect filter.

#5 @johnbillion
10 years ago

Good point.

#6 @SergeyBiryukov
10 years ago

27617.2.patch passes the original 'redirect_to' value as well.

#7 @johnbillion
10 years ago

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

In 31417:

Introduce a logout_redirect filter so the redirect destination can be changed when a user logs out. Parameters:

  • string $redirect_to The redirect destination URL.
  • string $requested_redirect_to The requested redirect destination URL passed as a parameter.
  • WP_User $user The WP_User object for the user that's logging out.

Fixes #27617
Props SergeyBiryukov, johnbillion

Note: See TracTickets for help on using tickets.