Skip to:
Content
Pages
Categories
Search
Top
Bottom

MODIFY: Topic/Reply Author's Forum Role Display


  • Spudnic
    Participant

    @spudnic072

    So, right now with my un-edited bbPress installation on the forum pages, the authors role is displayed as KeyMaster::1, and so on and so forth depending on the forum role of the author of the topic / reply. Is there a way to change what is displayed there? I would like it to display possibly my wordpress user roles rather than the forum roles, or maybe to display something else once I figure out how to modify the display.

    Is this possible?

    I don’t really want to edit core bbPress files so i thought i would try to make a plugin that would just change them.

    Any and all replies are much appreciated. Thanks.

    This is my site / theme and you can see what im referring to on this page:

    http://oqueuefansitedev.co.nf/?topic=a-test-topic.

Viewing 11 replies - 1 through 11 (of 11 total)
  • KeyMaster is the forum role, ::1 is the IP, you’re seeing that because you’re probably posting to localhost.

    Just a note on this, you’re only seeing that as the KeyMaster. The rest of the users don’t see that.

    If you want to add information in there, hook into the ‘bbp_theme_after_reply_author_details’ action. Like:

     

    `
    add_action( ‘bbp_theme_after_reply_author_details’, ‘my_custom_info’ );

    function my_custom_info(){
    echo “Here it goes!”;
    }
    `


    Spudnic
    Participant

    @spudnic072

    Thank you for your speedy reply.

    This is working great for adding additional information.

    But how can i edit what is already displayed in that field by default? IE; totally remove the author role and even author name so i can display custom links there.

    you may have already touched on this in my other thread, i will need to re-read it more carefully.

    Copy bbpress/templates/default/bbpress/loop-single-reply.php into a bbpress folder in your theme, and in that copy remove from:

    ` if ( bbp_is_user_keymaster() ) : `

    and
    ` endif; `


    Spudnic
    Participant

    @spudnic072

    Doing the above ^ didnt seem to change anything?

    I did however change

    `bbp_reply_author_link( array( ‘sep’ => ”, ‘show_role’ => false ) ); `

    from true to false. It appears to accomplish what i want it to, but wasn’t sure if it would mess anything else up that relied on it?

    Is this the proper way to hide the users forum role?

    Thanks.

    Seems ok, as long as you change that in your theme’s copy of the file and not in core.


    Spudnic
    Participant

    @spudnic072

    on an unrelated topic;

    i have `bbp_get_reply_id()`, which is getting me the id of the topic reply, and im trying to use it to get the id of the author so that i can print any of the authors meta data, role, name, url, etc.

    Does bbPress have a method for getting the author id? Sofar using
    `
    $comment = get_comment( bbp_get_reply_id() );
    $comment_author_id = $comment->user_id;
    `

    returns me my favorite:

    Notice: Trying to get property of non-object in C:\xampp\htdocs\wordpress\wp-content\themes\WoW_Public_Vent_Theme\functions.php on line 275


    Spudnic
    Participant

    @spudnic072

    `$id = get_comment(bbp_get_reply_id(), OBJECT)->user_id;
    echo $id;`

    Doesn’t seem to want to work either :/

    Replies are not comments.

    `bbp_get_reply_author_id( bbp_get_reply_id() );` will give you what you need.

    Let me recommend you to give a good look at the bbPress source code. It’s surprisingly well documented.


    Spudnic
    Participant

    @spudnic072

    Thanks again, ill look through the code some.


    Spudnic
    Participant

    @spudnic072

    `
    $user_id = get_userdata( bbp_get_reply_author_id( bbp_get_reply_id() ) ); // Return the get_userdata information
    $user = new WP_User( $user_id );
    if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
    $roles = $user->roles;
    echo $roles[0]; //echos only the first role index of 0 of array $roles;
    /* Echos all roles
    foreach ( $user->roles as $role )
    echo $role.””; */
    }
    `

    Accomplished Display the Replies author’s role with the Above ^. Seems like alot of code for such a simple thing but it works :D. Thanks.

    get_userdata already returns you the WP_User object. This should do it:

    `
    $user = get_userdata( bbp_get_reply_author_id( bbp_get_reply_id() ) );
    if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
    echo $user->roles[0];
    }
    `

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