• Please if you can assist me I would like to display following {1} followers {1} in my front-page how can I do this please

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mostafa Shahiri

    (@mostafadeveloper)

    Hi
    This plugin is created to show the number of followers/followings based on user’s profile you visit and you must be a user of website (you must login) to see followings/followers information. Now, if you like to display followings/followers count for current logged in user, please follow this steps:

    step 1) open shortcode.php file, go to the end of file and add following code:

    
    function bbpf_display_follow_count(){
     $user_id = get_current_user_id();
     $output ='';
     if(!empty($user_id))
     {
        $follow_info = array_map( function( $a ){ return $a[0]; }, get_user_meta( $user_id ) );
        $followers_count = (!empty($follow_info['bbpress_followers']))? intval($follow_info['bbpress_followers']):0;
        $following_count = (!empty($follow_info['bbpress_following']))? intval($follow_info['bbpress_following']):0;
            $output ='<div class="follow_box_container">';
        $output .= '<div class="bbpf_followers" >'.__('Followers:','follow-for-bbpress').' '.$followers_count.'</div>';
        $output .= '<div class="bbpf_following" >'.__('Following:','follow-for-bbpress').' '.$following_count.'</div></div>';
    
     }
     echo $output;
    }
    add_shortcode('bbpress_follow_count','bbpf_display_follow_count'); 
    

    We define a shortcode (bbpress_follow_count) for displaying followers/followings count.
    step 2) Now you can use [bbpress_follow_count] shortcode to display followers/followings count. Place it everywhere you want.

    Plugin Author Mostafa Shahiri

    (@mostafadeveloper)

    In above code, please change ‘echo’ to ‘return’ in last line of the function.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How can I get followers count on front-page’ is closed to new replies.