Skip to:
Content

bbPress.org


Ignore:
Timestamp:
08/07/2011 05:07:54 AM (13 years ago)
Author:
johnjamesjacoby
Message:

Allow previously set $redirect_to override in bbp_logout_url(). Fixes #1580.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-common-functions.php

    r3382 r3387  
    899899function bbp_logout_url( $url = '', $redirect_to = '' ) {
    900900
    901     // Rejig the $redirect_to
    902     if ( !isset( $_SERVER['REDIRECT_URL'] ) || ( !$redirect_to = home_url( $_SERVER['REDIRECT_URL'] ) ) )
    903         $redirect_to = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '';
    904 
    905901    // Make sure we are directing somewhere
    906     if ( empty( $redirect_to ) )
     902    if ( empty( $redirect_to ) && !strstr( $url, 'redirect_to' ) ) {
     903
     904        // Rejig the $redirect_to
     905        if ( !isset( $_SERVER['REDIRECT_URL'] ) || ( $redirect_to != home_url( $_SERVER['REDIRECT_URL'] ) ) ) {
     906            $redirect_to = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '';
     907        }
     908
    907909        $redirect_to = home_url( isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '' );
    908910
    909     // Sanitize $redirect_to and add it to full $url
    910     $redirect_to = esc_url( add_query_arg( array( 'loggedout'   => 'true'       ), $redirect_to ) );
    911     $url         =          add_query_arg( array( 'redirect_to' => $redirect_to ), $url           );
     911        // Sanitize $redirect_to and add it to full $url
     912        $redirect_to = add_query_arg( array( 'loggedout'   => 'true'                    ), esc_url( $redirect_to ) );
     913        $url         = add_query_arg( array( 'redirect_to' => urlencode( $redirect_to ) ), $url                    );
     914    }
    912915
    913916    // Filter and return
Note: See TracChangeset for help on using the changeset viewer.