BuddyDev

Search

Followers tab in member directory of buddyboss

  • Participant
    Level: Enlightened
    Posts: 48
    Eric Hinz on #52404

    Hi,
    I found this information: https://buddydev.com/support/forums/topic/display-followers-tab-in-members-directory/

    This is what I need but it don’t works in my Buddyboss site. May be I have to change some things.

    Are you able to check this and to give a hint, how I can add a tab with followers in the Buddyboss member directory? That would be great!

    Thanks, kind regads
    Eric

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #52417

    Hi Eric,
    Thank you for the question.
    I believe you don’t need that snippet in BuddyBoss.

    If you enable follow in BuddyBoss, They should add the menu in your members directory.

    Please check.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 48
    Eric Hinz on #52453

    Hi Brajesh,
    Thanks, yes “Following”, means members, the user is following, is already in the Buddyboss enabled, but a tab with “Followers”, means members, who follow the user, is missing. There is only a widget available.
    Therefore would be great, if a tab with Followers could be addded in the members directory.
    Thanks, kind regards
    Eric

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #52500

    Hi Eric,
    Thank you.

    Please put this code in your bp-custom.php

    
    
    function bp_custom_add_member_follower_scope_filter( $qs, $object ) {
    	// not on the members object? stop now!
    	if ( 'members' !== $object ) {
    		return $qs;
    	}
    
    	// members directory
    	if ( ! bp_is_user() && bp_is_members_directory() ) {
    		$qs_args = bp_parse_args( $qs );
    		// check if members scope is follower before manipulating.
    		if ( isset( $qs_args['scope'] ) && 'follower' === $qs_args['scope'] ) {
    			$qs .= '&include=' . bp_get_follower_ids(
    					array(
    						'user_id' => bp_loggedin_user_id(),
    					)
    				);
    		}
    	}
    
    	return $qs;
    }
    
    add_filter( 'bp_ajax_querystring', 'bp_custom_add_member_follower_scope_filter', 30, 2 );
    
    /**
     * Add a "Following (X)" tab to the members directory.
     *
     * This is so the logged-in user can filter the members directory to only
     * users that the current user is following.
     *
     * @uses bp_follow_total_follow_counts() Get the following/followers counts for a user.
     */
    function bp_custom_follower_add_following_tab() {
    
    	if ( ! is_user_logged_in() ) {
    		return;
    	}
    
        // BuggyBoss has some messed up code, so this won't work.
    	$count = bb_get_followers_count( get_current_user_id() );
    
    	if ( empty( $count ) ) {
    		// return;
    	}
    
        $count = 0 ;// Ask BuddyBoss, not me.
    
    	?>
    
        <li id="members-follower">
            <a href="#"><?php printf( __( 'Followers<span>%d</span>', 'buddypress-followers' ), esc_html( $count ) ) ?></a>
        </li>
    
    	<?php
    }
    
    add_action( 'bp_members_directory_member_types', 'bp_custom_follower_add_following_tab' );
    
    

    It won’t show you the count initially as there is a bug in BuddyBoss, but clicking the tab will update the count and show the followers.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 48
    Eric Hinz on #52502

    Hi Brajesh,

    Great work, thank you very much, I had been looking for a solution here for so long, very good! I am very grateful to you!

    I see that at the start of the page the counter is (0) and then, by clicking the link the number changes to the correct number.

    You say, that is a Buddyboss bug: please can you tell me more, so that I can address this to Buddyboss? I would like to do that.

    Another question: can I overcome this error with an overwrite template?

    Thanks, kind regards
    Eric

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #52504

    Hi Eric,
    You are welcome. I am happy it worked partially.

    The problem lies with

    
    bb_get_followers_count() 
    

    function. The function does not return follower count and seems to be named badly. Can you please ask them to provide us with a function that returns the actual count.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 48
    Eric Hinz on #52513
    This reply has been marked as private.
  • Participant
    Level: Enlightened
    Posts: 48
    Eric Hinz on #52533
    This reply has been marked as private.
  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #52539
    This reply has been marked as private.

You must be logged in to reply to this topic.

This topic is: not resolved