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

Built from https://develop.svn.wordpress.org/trunk@31417


git-svn-id: http://core.svn.wordpress.org/trunk@31398 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2015-02-11 19:19:26 +00:00
parent a7e581d991
commit 35f4e719b2
2 changed files with 21 additions and 2 deletions

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-alpha-31416';
$wp_version = '4.2-alpha-31417';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -484,9 +484,28 @@ case 'postpass' :
case 'logout' :
check_admin_referer('log-out');
$user = wp_get_current_user();
wp_logout();
$redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : 'wp-login.php?loggedout=true';
if ( ! empty( $_REQUEST['redirect_to'] ) ) {
$redirect_to = $requested_redirect_to = $_REQUEST['redirect_to'];
} else {
$redirect_to = 'wp-login.php?loggedout=true';
$requested_redirect_to = '';
}
/**
* Filter the log out redirect URL.
*
* @since 4.2.0
*
* @param string $redirect_to The redirect destination URL.
* @param string $requested_redirect_to The requested redirect destination URL passed as a parameter.
* @param WP_User $user The WP_User object for the user that's logging out.
*/
$redirect_to = apply_filters( 'logout_redirect', $redirect_to, $requested_redirect_to, $user );
wp_safe_redirect( $redirect_to );
exit();