Skip to content

Commit

Permalink
Introduce a logout_redirect filter so the redirect destination can …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
johnbillion committed Feb 11, 2015
1 parent a7e581d commit 35f4e71
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion wp-includes/version.php
Expand Up @@ -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.
Expand Down
21 changes: 20 additions & 1 deletion wp-login.php
Expand Up @@ -484,9 +484,28 @@ function retrieve_password() {

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();

Expand Down

0 comments on commit 35f4e71

Please sign in to comment.