Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum reply redirect URL rewrite issue

Viewing 2 replies - 26 through 27 (of 27 total)

  • iamnotadoll
    Participant

    @iamnotadoll

    I modified the code in includes/common/template-tags.php as outlined on this page and (for now) it seems to have fixed the issue.

    `
    function bbp_redirect_to_field( $redirect_to = ” ) {

    // Rejig the $redirect_to
    //if ( !isset( $_SERVER['REDIRECT_URL'] ) || ( !$redirect_to == home_url( $_SERVER['REDIRECT_URL'] ) ) )
    // $redirect_to = wp_get_referer();

    // Make sure we are directing somewhere
    if ( empty( $redirect_to ) )
    $redirect_to = home_url( isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : wp_get_referer() );

    // Remove loggedout query arg if it’s there
    $redirect_to = (string) esc_attr( remove_query_arg( ‘loggedout’, $redirect_to ) );
    $redirect_field = ”;

    echo apply_filters( ‘bbp_redirect_to_field’, $redirect_field, $redirect_to );
    }
    `

    Initially it wasn’t working because I didn’t remove the //Rejig the redirect part (can’t believe I didn’t see it the first time).

    Now my question is, where (and how) would I put this modified function to stop any future updates from overwriting it?

    I tried using add_filter(‘bbp_redirect_to_field’) in my bbpress-functions file but it makes the site really slow. Is there a better way to do it?

    `
    add_filter(‘bbp_redirect_to_field’, ‘bbp_redirect_to_field_filter’);

    /**
    * Filter to fix the reply redirects
    **/
    function bbp_redirect_to_field_filter( $redirect_to = ” ) {

    // Make sure we are directing somewhere
    if ( empty( $redirect_to ) )
    $redirect_to = home_url( isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : wp_get_referer() );

    // Remove loggedout query arg if it’s there
    $redirect_to = (string) esc_attr( remove_query_arg( ‘loggedout’, $redirect_to ) );
    $redirect_field = ”;

    echo apply_filters( ‘bbp_redirect_to_field’, $redirect_field, $redirect_to );
    }

    `

    With what you patched via #1835.diff that is the same as what was committed to /trunk in r4533 and is included in the upcoming bbPress 2.3.

Viewing 2 replies - 26 through 27 (of 27 total)

You must be logged in to reply to this topic.