Title: [Plugin: bbPress] Bug with bbp_logout_url &#8211; Logout link not redirecting properly
Last modified: August 20, 2016

---

# [Plugin: bbPress] Bug with bbp_logout_url – Logout link not redirecting properly

 *  [Doug](https://wordpress.org/support/users/spheric1/)
 * (@spheric1)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-bbpress-bug-with-bbp_logout_url/)
 * 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](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](http://www.example.com/wordpress/wordpress/page.php)
   rather than the correct [http://www.example.com/wordpress/page.php](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
 * [http://wordpress.org/extend/plugins/bbpress/](http://wordpress.org/extend/plugins/bbpress/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [gab.ro](https://wordpress.org/support/users/gabro/)
 * (@gabro)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-bbpress-bug-with-bbp_logout_url/#post-2489100)
 * Yes, I have also experienced this problem.
 *  [gab.ro](https://wordpress.org/support/users/gabro/)
 * (@gabro)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-bbpress-bug-with-bbp_logout_url/#post-2489101)
 * I just did: `remove_filter('logout_url', 'bbp_logout_url', 2);`
 *  [id_elias](https://wordpress.org/support/users/id_elias/)
 * (@id_elias)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-bbpress-bug-with-bbp_logout_url/#post-2489217)
 * hello friends .. exactly what is the edited **file**?
 *  [AnitaH](https://wordpress.org/support/users/anitah/)
 * (@anitah)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-bbpress-bug-with-bbp_logout_url/#post-2489220)
 * Doug … your logout link bug fix worked perfectly. Thank you!!!!
 *  [dorsetjon](https://wordpress.org/support/users/dorsetjon/)
 * (@dorsetjon)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/plugin-bbpress-bug-with-bbp_logout_url/#post-2489227)
 * Hi,
 * I found this is a known issue logged in Ticket #1645.
 * The fix is to edit the following file:
 * bbp-includes/bbp-common-functions.php
 * Line 1074 should be changed from:
 * $redirect_to = home_url( isset( $_SERVER[‘REQUEST_URI’] ) ? $_SERVER[‘REQUEST_URI’]:”);
 * To:
 * $redirect_to = ( is_ssl() ? ‘[https://&#8217](https://&#8217); : ‘[http://&#8217](http://&#8217);).
   $_SERVER[‘HTTP_HOST’] . $_SERVER[‘REQUEST_URI’];
 * That fix worked for me.
 * Hopefully this will be included in the official release soon.
 * Jon
 *  [looogo](https://wordpress.org/support/users/looogo/)
 * (@looogo)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-bbpress-bug-with-bbp_logout_url/#post-2489271)
 * dorsetjon,
 * your suggestion worked perfectly. thanks a lot.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘[Plugin: bbPress] Bug with bbp_logout_url – Logout link not redirecting
properly’ is closed to new replies.

 * ![](https://ps.w.org/bbpress/assets/icon.svg?rev=978290)
 * [bbPress](https://wordpress.org/plugins/bbpress/)
 * [Support Threads](https://wordpress.org/support/plugin/bbpress/)
 * [Active Topics](https://wordpress.org/support/plugin/bbpress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/bbpress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/bbpress/reviews/)

 * 6 replies
 * 6 participants
 * Last reply from: [looogo](https://wordpress.org/support/users/looogo/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-bbpress-bug-with-bbp_logout_url/#post-2489271)
 * Status: not resolved