Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] How to show total friends of display user (2)


  • Florence Baby
    Participant

    @okuleyeflo

    Hi, Please can someone help me out on how to show total friends count any where e.g sidebar.

    I have tried <p> My Total Friends ( <?php echo friends_get_total_friend_count( $user_id );?> )</p> but it is not working.

    I am using latest wordpress and buddypress.

    Thanks for your help.

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

  • meg@info
    Participant

    @megainfo

    hi,

    try this

    
    friends_get_friend_count_for_user( $user_id );
    
    

    Or this if you call it in a member page :

    
    friends_get_total_friend_count()
    

    danbp
    Moderator

    @danbp

    Hi @okuleyeflo,

    give this a try. Use it in bp-custom.php or functions.php of your theme.
    Tested on BP 1.8.1 with bp-default theme

    function bpfr_my_total_friends() {
    
    	if ( is_user_logged_in() ) :
    		if ( bp_is_active( 'friends' ) ) :	
    
    			echo '<br/><br/>My Total Friends:&nbsp;'. bp_get_total_friend_count( $user_id ) .'';
    			  
    		endif;
    	endif;
    
    }
    
    add_filter ( 'bp_sidebar_me', 'bpfr_my_total_friends');

    Open bp-default/sidebar.php to see on witch placeholder (do_action…) of the sidebar you want to use the function.
    The above example use bp_sidebar_me who shows the counter underneath the login/logout button


    Florence Baby
    Participant

    @okuleyeflo

    Thanks @megainfo, for your input,


    @danbp
    , thank you so much, that did the trick

    Regards

    @okuleyeflo,

    I just released a widget plugin which shows photos and names of user’s friends or current viewing member’s friends and it shows total friends count aswell a link to view all. something similar to Facebook. you can have a look if it may be useful.

    https://wordpress.org/plugins/bp-facebook-style-friend-lists/screenshots/

    Naijaping

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] How to show total friends of display user (2)’ is closed to new replies.
Skip to toolbar