Skip to:
Content
Pages
Categories
Search
Top
Bottom

bbpress 2.0 plugin: Adding a log in/out link to the top of every forum page


  • hlwinkler
    Participant

    @hlwinkler

    Hello,

    I have sorted out my migration from a standalone 1.0 installation in a separate db to a 2.0 plugin installation on my own, and now I would like to restore the functionality of bbpress 1.0 of having a log in/out link and a username for the logged-in user at the top of every forum page. I don’t want this at the top of every page on my site, just on every forum page. Here is the approximate code I would use if I were to add this to a WP header somewhere:

    <?php if ( is_user_logged_in() ) { ?>

    get_currentuserinfo();

    <p>

    echo ‘Welcome ‘ . $current_user->user_login . Click here to log out“n”;

    </p>

    <?php } else { ?>

    <p>” title=”Login”>Log in to post if you are registered, or /wp-register.php”>register an account.</p>

    <?php } ?>

    Can someone help me integrate the same functionality into bbp-common-template.php or wherever it ought to go in order to be shown on every forum page but not on any pages that aren’t part of my forum? I would like it to appear right below the breadcrumbs on every page.

    While I’m here, I’d like to strongly recommend building this functionality into the bbpress plugin, since there are probably many people other than me who don’t want to encourage login attempts (or use up primary menu navigation space) for any pages other than their dedicated forums.

    Thank you!

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

  • hlwinkler
    Participant

    @hlwinkler

    Here is what I eventually figured out — it would be great if someone would let me know a) if there is an easier way to do this and b) if they see any security issues in here, since I am not a PHP programmer or frequently working with WP or bbpress. Thank you.

    This replaces the breadcrumbs block between the comments

    /** Current ***********************************************************/

    and

    /** Finish Up *********************************************************/

    in bbp-common-template.php in the neighborhood of lines 1421 to 1428:

    /** Current ***********************************************************/
    // Add current page to breadcrumb
    global $current_user;
    get_currentuserinfo();
    $bb2custom_user_is_logged_in = 'Welcome '.$current_user->user_login.'. You can log out <a href='.wp_logout_url( get_permalink() ).'>here</a>.';
    $bb2custom_user_is_logged_out = "You aren't logged in. <a href=".wp_login_url( get_permalink() ).">Log in here</a> or <a href='http://www.example.com/wp-login.php?action=register'>register</a> if you don't have an account.";
    if ( is_user_logged_in() ) {
    $bb2custom_loginoutregister = $bb2custom_user_is_logged_in;
    } else {
    $bb2custom_loginoutregister = $bb2custom_user_is_logged_out;
    }
    if ( !empty( $include_current ) || empty( $pre_current_text ) )
    $breadcrumbs[] = '<span class="bbp-breadcrumb-current">' . $current_text . '</span><p>' .$bb2custom_loginoutregister. '</p>';
    /** Finish Up *********************************************************/


    JKNN
    Member

    @jknn

    I just tried the above with the newest wordpress and bbpress available. It does not work :(

    Does anybody have a solution?

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

You must be logged in to reply to this topic.