WordPress.org

Ready to get started?Download WordPress

Forums

bbPress
Bug with bbp_logout_url - Logout link not redirecting properly (7 posts)

  1. Doug
    Member
    Posted 2 years ago #

    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

    http://wordpress.org/extend/plugins/bbpress/

  2. gab.ro
    Member
    Posted 2 years ago #

    Yes, I have also experienced this problem.

  3. gab.ro
    Member
    Posted 2 years ago #

    I just did: remove_filter('logout_url', 'bbp_logout_url', 2);

  4. id_elias
    Member
    Posted 2 years ago #

    hello friends .. exactly what is the edited file?

  5. AnitaH
    Member
    Posted 2 years ago #

    Doug ... your logout link bug fix worked perfectly. Thank you!!!!

  6. dorsetjon
    Member
    Posted 2 years ago #

    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://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

    That fix worked for me.

    Hopefully this will be included in the official release soon.

    Jon

  7. looogo
    Member
    Posted 1 year ago #

    dorsetjon,

    your suggestion worked perfectly. thanks a lot.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags