Make WordPress Core


Ignore:
Timestamp:
02/11/2015 07:18:19 PM (10 years ago)
Author:
johnbillion
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-login.php

    r31090 r31417  
    485485case 'logout' :
    486486    check_admin_referer('log-out');
     487
     488    $user = wp_get_current_user();
     489
    487490    wp_logout();
    488491
    489     $redirect_to = !empty( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : 'wp-login.php?loggedout=true';
     492    if ( ! empty( $_REQUEST['redirect_to'] ) ) {
     493        $redirect_to = $requested_redirect_to = $_REQUEST['redirect_to'];
     494    } else {
     495        $redirect_to = 'wp-login.php?loggedout=true';
     496        $requested_redirect_to = '';
     497    }
     498
     499    /**
     500     * Filter the log out redirect URL.
     501     *
     502     * @since 4.2.0
     503     *
     504     * @param string  $redirect_to           The redirect destination URL.
     505     * @param string  $requested_redirect_to The requested redirect destination URL passed as a parameter.
     506     * @param WP_User $user                  The WP_User object for the user that's logging out.
     507     */
     508    $redirect_to = apply_filters( 'logout_redirect', $redirect_to, $requested_redirect_to, $user );
    490509    wp_safe_redirect( $redirect_to );
    491510    exit();
Note: See TracChangeset for help on using the changeset viewer.