Skip to:
Content
Pages
Categories
Search
Top
Bottom

redirect after login error

Viewing 6 replies - 1 through 6 (of 6 total)
  • @finalwebsites

    Participant

    just checked the code and it seems to me that this function is not 100% fine:

    function new_topic( $args = null ) {
    $defaults = array( 'text' => __('Add New »'), 'forum' => 0, 'tag' => '' );
    if ( $args && is_string($args) && false === strpos($args, '=') )
    $args = array( 'text' => $args );

    $args = wp_parse_args( $args, $defaults );
    extract( $args, EXTR_SKIP );

    if ( $forum && $forum = get_forum( $forum ) )
    $url = get_forum_link( $forum->forum_id ) . '#postform';
    elseif ( $tag && ( ( is_numeric($tag) && $tag = bb_get_tag( $tag ) ) || $tag = bb_get_tag_by_name( $tag ) ) )
    $url = bb_get_tag_link( $tag->tag ) . '#postform';
    elseif ( is_forum() || is_bb_tag() )
    $url = '#postform';
    elseif ( is_topic() )
    $url = get_forum_link() . '#postform';
    elseif ( is_front() )
    $url = add_query_arg( 'new', '1', bb_get_option( 'uri' ) );

    if ( !bb_is_user_logged_in() )
    $url = add_query_arg( 're', urlencode($url), bb_get_option( 'uri' ) . 'bb-login.php' );
    elseif ( is_forum() || is_topic() ) {
    if ( !bb_current_user_can( 'write_topic', get_forum_id() ) )
    return;
    } else {
    if ( !bb_current_user_can( 'write_topics' ) )
    return;
    }

    if ( $url = attribute_escape( apply_filters( 'new_topic_url', $url ) ) )
    echo "<a href='$url' class='new-topic'>$text</a>n";
    }

    this part is not good and result im some error:

    elseif ( is_forum() || is_bb_tag() )
    $url = '#postform';

    what is your adbvice to fix that? rewriting the function / adding a filter as a kind of plugin?

    @finalwebsites

    Participant

    as a work arround, I use this value for the hidden field “re”:

    <?php
    if ($re == 'http://#postform') {
    echo $_SERVER['HTTP_REFERER'].'#postform';
    } else {
    $re;
    }
    ?>

    @sambauers

    Participant

    The only real problem you have is that the Warning is being printed to screen. On a production site you shouldn’t print PHP errors on the screen.

    The warning in that case should be dealt with though and I will do so in trunk for 1.0. If you want to modify the bb_safe_redirect() function then use the below code for a plugin to rid you of the warning.

    <?php
    /*
    Plugin Name: Suppress bb_safe_redirect Warnings
    Plugin URI:
    Description:
    Author:
    Author URI:
    Version: 0.1
    */

    function bb_safe_redirect($location, $status = 302) {

    // Need to look at the URL the way it will end up in wp_redirect()
    $location = wp_sanitize_redirect($location);

    // browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//'
    if ( substr($location, 0, 2) == '//' )
    $location = 'http:' . $location;

    $home = bb_get_uri(null, null, BB_URI_CONTEXT_HEADER);

    if ( !$lp = @parse_url($location) )
    return wp_redirect($home, $status);

    $wpp = parse_url(bb_get_uri());

    $allowed_hosts = (array) apply_filters('allowed_redirect_hosts', array($wpp['host']), isset($lp['host']) ? $lp['host'] : '');

    if ( isset($lp['host']) && !in_array($lp['host'], $allowed_hosts) )
    return wp_redirect($home, $status);

    return wp_redirect($location, $status);
    }
    ?>

    @income-tax

    Member

    It did not worked for me :(

    @lyrics

    Member

    If the user is not logged in on to bbpress 9.0.2, “add new” option should not be available for him.I hope this feature would be taken care in higher versions.

    @ipstenu

    Moderator

    Change all instances of ' to

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar