WordPress.org

Forums

BuddyPress Follow
Added Followers Widget (5 posts)

  1. stoi2m1
    Member
    Posted 3 years ago #

    I added a followers widget to the plugin. Would you like to a copy of the code?

    http://wordpress.org/extend/plugins/buddypress-followers/

  2. Sarah Gooding
    Member
    Posted 3 years ago #

    I would like a copy of it, even if the plugin developer isn't interested. I think it would be very useful for a number of BuddyPress sites.

  3. stoi2m1
    Member
    Posted 3 years ago #

    place this code in the file buddypress-followers\_inc\bp-follow-widgets.php

    /**
     * Add a "Users I'm following" widget for the logged-in user
     *
     * @subpackage Widgets
     */
    class BP_Follow_Followers_Widget extends WP_Widget {
    	function bp_follow_followers_widget() {
    		parent::WP_Widget( false, $name = __( "Users Following Me", 'bp-follow' ) );
    	}
    
    	function widget( $args, $instance ) {
    
    		extract( $args );
    
    		if ( empty( $instance['max_users'] ) )
    			$instance['max_users'] = 25;
    
    		if ( !$following = bp_get_follower_ids( array( 'user_id' => bp_loggedin_user_id() ) ) )
    			return false;
    
    		if ( bp_has_members( 'include=' . $following . '&max=' . $instance['max_users'] ) ) {
    
    			do_action( 'bp_before_following_widget' );
    
    			echo $before_widget;
    			echo $before_title
    			   . __( 'Followers', 'bp-follow' )
    			   . $after_title; ?>
    
    			<div class="avatar-block">
    				<?php while ( bp_members() ) : bp_the_member(); ?>
    					<div class="item-avatar">
    						<a title="<?php bp_member_name() ?>" href="<?php bp_member_permalink() ?>"><?php bp_member_avatar() ?></a>
    					</div>
    				<?php endwhile; ?>
    			</div>
    
    			<?php echo $after_widget; ?>
    
    			<?php do_action( 'bp_after_following_widget' ); ?>
    
    		<?php } ?>
    
    	<?php
    	}
    
    	function update( $new_instance, $old_instance ) {
    		$instance = $old_instance;
    		$instance['max_users'] = strip_tags( $new_instance['max_users'] );
    
    		return $instance;
    	}
    
    	function form( $instance ) {
    		$instance = wp_parse_args( (array) $instance, array( 'max_users' => 25 ) );
    		$max_users = strip_tags( $instance['max_users'] );
    		?>
    
    		<p><label for="bp-follow-widget-users-max"><?php _e('Max users to show:', 'bp-follow'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_users' ); ?>" name="<?php echo $this->get_field_name( 'max_users' ); ?>" type="text" value="<?php echo attribute_escape( $max_users ); ?>" style="width: 30%" /></label></p>
    	<?php
    	}
    }
    add_action( 'widgets_init', create_function( '', 'return register_widget("BP_Follow_Followers_Widget");' ) );
  4. Sarah Gooding
    Member
    Posted 3 years ago #

    Awesome, thank you so much! I will give it a test this week. :)

  5. Eric Langley
    Member
    Posted 2 years ago #

    Sarah,

    Did this work?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • BuddyPress Follow
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.