Skip to:
Content
Pages
Categories
Search
Top
Bottom

Number of Topics and Replies in Profile


  • Matthias
    Participant

    @matthias70

    In my bbpress profiles the users could see the number of topics and replies of in each userprofile. The profile in buddypress shows nothing.
    How can I show the number of topics and replies of each user?

    Thanks
    Matthias

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

  • Matthias
    Participant

    @matthias70

    Want to show number of
    topics created:
    replies created:

    in the buddypress user profile.
    bbpress without buddypress did the job without modification…

    Any ideas?


    danbp
    Participant

    @danbp

    Hi @matthias70,

    try this. Will show 2 lines of stats on the profile header. Add to bp-custom.php

    function bpfr_topics_stat( $user_id, $type = 'topic' ) {
    global $bp;
    // Check if bbPress plugin is loaded
    if ( class_exists( 'bbPress' ) ) {
    
    	if( bp_is_user() && ! bp_get_member_user_id() ) {
            $user_id = 'displayed: '. bp_displayed_user_id();
        } else {
            $user_id = 'get_member_user: '. bp_get_member_user_id();
        }
    
      	$query = new WP_Query( array('post_type'=>$type,'author'=>$user_id) );				
    	
    	if ( $query->have_posts() ) {
    		echo '<p>Topics created: '. $query->post_count .'</p>';
    	}
    	else{
    		echo '<p>Topics created: 0</p>';
    	}
      }
    }
    add_action( 'bp_before_member_header_meta', 'bpfr_topics_stat', 2 );
    
    function bpfr_replies_stat( $user_id, $type = 'reply' ) {
    global $bp;
    // Check if bbPress plugin is loaded
    if ( class_exists( 'bbPress' ) ) {
    
    	if( bp_is_user() && ! bp_get_member_user_id() ) {
            $user_id = 'displayed: '. bp_displayed_user_id();
        } else {
            $user_id = 'get_member_user: '. bp_get_member_user_id();
        }
    
      	$query = new WP_Query( array('post_type'=>$type,'author'=>$user_id) );				
    	
    	if ( $query->have_posts() ) {
    		echo '<p>Replies created: '. $query->post_count .'</p>';
    	}
    	else{
    		echo '<p>Replies created: 0</p>';
    	}
      }
    }
    add_action( 'bp_before_member_header_meta', 'bpfr_replies_stat', 2 );

    shanebp
    Moderator

    @shanebp

    Wouldn’t this work? Or am I missing something?

    $topic_count = bp_forums_total_topic_count_for_user( bp_displayed_user_id() );
    
    $reply_count = bp_forums_total_replied_count_for_user( bp_displayed_user_id() );

    danbp
    Participant

    @danbp

    No it doesn’t and is throwing an undefined function error, filters only the forums template topics. bbPress also has a similar function which cannot be used outside of the forum template.


    Matthias
    Participant

    @matthias70

    Hi @danbp,
    the code blows up my function.php 🙂 At the moment I’m at line 330, but it works like a charm.
    Where did you hide this piece of code? And do you have other code snippets like this?
    I searched the web, but I did not find it…
    Thanks
    Matthias


    danbp
    Participant

    @danbp

    I would rather use it from within bp-custom.php, so you stay independant of the theme and can change theme without loosing these 2 functions.

    Don’t know What is line 330 ? What are you doing at line 330 ?
    What should i hide ?
    If i have other snippets ? Huh… 🙄 why this question ?


    Matthias
    Participant

    @matthias70

    Don’t know What is line 330 ? What are you doing at line 330 ?
    What should i hide ?
    If i have other snippets ? Huh… 🙄 why this question ?

    Just want to say, that my functions.php is now 330 lines long 😉
    And I asked, if you have a repository with other code snippets like the above.
    At the moment I know only http://bp-tricks.com/

    Matthias


    danbp
    Participant

    @danbp

    Yes i have, but in french and sometimes in english… http://snippetbarn.bp-fr.net/


    Matthias
    Participant

    @matthias70

    Yes i have, but in french and sometimes in english… http://snippetbarn.bp-fr.net/

    Thanks for the link
    Matthias


    Vignesh M
    Participant

    @vignesh-m

    hi there !! i want to show specific user for forums count, replies counts, and topic counts in this page http://test06.aachicargo.com/members/ without logged on

    Anyone kindly help me….

    Thanks in Advance

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Number of Topics and Replies in Profile’ is closed to new replies.
Skip to toolbar