WordPress.org

Ready to get started?Download WordPress

Forums

BuddyPress FollowMe
[resolved] Followers instead of following (3 posts)

  1. hornets2002
    Member
    Posted 1 year ago #

    Hey, great plugin!

    It's very simple to use yet very effective. I was wondering though if it was possible to alter the widget or make a new one that shows the people following you instead of the people you are following.

    And also is it possible to make the widget show the followers of a user according to bp_displayed_user_id()?

    Thanks in advanced! :)

    http://wordpress.org/extend/plugins/buddypress-follow-me/

  2. hornets2002
    Member
    Posted 1 year ago #

    Nevermind!

    I found a solution through buddypress forums. For anybody else looking for this feature, you must go to to the plugin folder, includes and then edit bp-follow-widgets.php.

    Just delete all the code in there and replace it with this:

    <?php
    /**
     * BP Follow Widgets
     *
     * @package BP-Follow
     * @subpackage Widgets
     */
    
    // Exit if accessed directly
    if ( !defined( 'ABSPATH' ) ) exit;
    
    /**
     * Add a "Users I'm following" widget for the logged-in user
     *
     * @subpackage Widgets
     */
    class BP_Follow_Following_Widget extends WP_Widget {
    	function bp_follow_following_widget() {
    		parent::WP_Widget( false, $name = __( "BP Follow - Following", 'bp-follow' ) );
    	}
    
    	function widget( $args, $instance ) {
    
    		extract( $args );
    
    		if ( empty( $instance['max_users'] ) )
    			$instance['max_users'] = 25;
    
    		if ( !$following = bp_get_following_ids( $displayed_user->id ) )
    		{
    			do_action( 'bp_before_follower_widget' );
    
    			echo $before_widget;
    			echo $before_title
    			   . __( 'Following', 'bp-follow' )
    			   . $after_title; ?>
    
    			<div class="avatar-block">
    				<?php echo bp_get_displayed_user_fullname() . " " .  __('is not following anyone yet.', 'bp-follow'); ?>
    			</div>
    
    			<?php echo $after_widget; ?>
    
    			<?php do_action( 'bp_after_follower_widget' ); ?>
    
    		<?php } ?>
    
    		<?php
    
    		if ( bp_has_members( 'include=' . $following . '&max=' . $instance['max_users'] ) ) {
    
    			do_action( 'bp_before_following_widget' );
    
    			echo $before_widget;
    			echo $before_title
    			   . __( 'Following', '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_Following_Widget");' ) );
    
    /**
     * Add a "Users following me" widget for the logged-in user
     *
     * @subpackage Widgets
     */
    class BP_Follow_Follower_Widget extends WP_Widget {
    	function bp_follow_follower_widget() {
    		parent::WP_Widget( false, $name = __( "BP Follow - Followers", 'bp-follow' ) );
    	}
    
    	function widget( $args, $instance ) {
    
    		extract( $args );
    
    		if ( empty( $instance['max_users'] ) )
    			$instance['max_users'] = 25;
    
    		if ( !$follower = bp_get_follower_ids( $displayed_user->id ) )
    		{
    			do_action( 'bp_before_follower_widget' );
    
    			echo $before_widget;
    			echo $before_title
    			   . __( 'Followers', 'bp-follow' )
    			   . $after_title; ?>
    
    			<div class="avatar-block">
    				<?php echo bp_get_displayed_user_fullname() . " " .  __('has no followers yet.', 'bp-follow'); ?>
    			</div>
    
    			<?php echo $after_widget; ?>
    
    			<?php do_action( 'bp_after_follower_widget' ); ?>
    
    		<?php } ?>
    
    <?php
    		if ( bp_has_members( 'include=' . $follower . '&max=' . $instance['max_users'] ) ) {
    
    			do_action( 'bp_before_follower_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_follower_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_Follower_Widget");' ) );
    
    ?>

    And that's it, hope it helps someone

  3. hornets2002
    Member
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.