I experienced trouble with the redirect parameter in logout links. I tracked it down to the bbp_logout_url function. The problem is that home_url is not always just the base url, but can have directories as well. In the bbp_logout_url function, $_SERVER['REQUEST_URI'] is being appended to home_url (line 1074). However these may both contain some of the same directories. For example: home_url could return http://www.example.com/wordpress while $_SERVER['REQUEST_URI'] could be /wordpress/page.php resulting in a redirect url of http://www.example.com/wordpress/wordpress/page.php rather than the correct http://www.example.com/wordpress/page.php
I replaced line 1074:
$redirect_to = home_url( isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '' );
with the following:
if ( isset( $_SERVER['REQUEST_URI'] ) ) {
// determine what if any directories are in home_url()
$home_url = home_url();
$search = array( 'http://', 'https://' );
$replace = array( '', '' );
$directories = explode( '/', str_replace( $search, $replace, $home_url ) );
unset( $directories[0] ); // remove the base part of the url
$request_uri = $_SERVER['REQUEST_URI'];
foreach ( $directories as $directory ) {
// if a directory is found in both home_url and $_SERVER['REQUEST_URI'],
// remove it from $request_uri
$request_uri = str_replace('/'.$directory, '', $request_uri);
}
$redirect_to = home_url( $request_uri );
} else {
$redirect_to = '';
}
bbPress version 2.0.2