BuddyDev

Search

[Resolved] BuddyPress Profile Visibility Manager (follow support)

  • Participant
    Level: Guru
    Posts: 885
    Tosin on #51250

    Hi Brajesh

    Please can you add a new visibility option (My Followers) for the buddypress follow plugin

    Thanks

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #51261

    Hello Tosin,

    Thank you for posting. Please try the following code:

    
    
    add_filter( 'bp_profile_visibility_visiility_levels', function ( $visibilities ) {
    
    	if ( function_exists( 'bp_follow_is_following' ) && ! isset( $visibilities['followers'] ) ) {
    		$visibilities['followers'] = __( 'My Followers' );
    	}
    
    	return $visibilities;
    } );
    
    add_filter( 'bp_profile_visibility_is_visible_profile', function ( $can_see, $user_id, $visitor_id ) {
    
    	if ( function_exists( 'bp_follow_is_following' ) ) {
    		$privacy = bp_profile_visibility_get_settings( $user_id, 'bp_profile_visibility' );
    
    		if ( 'followers' === $privacy ) {
    			$can_see = bp_follow_is_following(
    				array(
    					'leader_id'   => $user_id,
    					'follower_id' => $visitor_id,
    				)
    			);
    		}
    	}
    
    	return $can_see;
    }, 10, 3 );
    
    

    Please let me know if it works or not.

    Regards
    Ravi

  • Participant
    Level: Guru
    Posts: 885
    Tosin on #51264

    Thanks Ravi

    The code worked perfectly

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #51266

    Hello Tosin,

    Thank you for the acknowledgement. I am glad that it worked.

    Regards
    Ravi

You must be logged in to reply to this topic.

This topic is: resolved