Skip to:
Content

BuddyPress.org

Opened 8 years ago

Closed 4 years ago

#5763 closed enhancement (maybelater)

Friends core widget: remove the echo

Reported by: danbp Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.0
Component: Friends Keywords: trac-tidy-2018
Cc: danco38@…

Description

I'm excluding some user_id to be shown in the Friends widget. By doing this, a 0 appears on the widget underneath the friends list.

https://buddypress.trac.wordpress.org/browser/trunk/src/bp-friends/bp-friends-widgets.php#L204

echo '0[[SPLIT]]';

return valid result. TODO: remove this.

So this ticket is much a reminder as a great bug. Thanks ! ;-)

Attachments (1)

5763.diff (1.1 KB) - added by imath 8 years ago.

Download all attachments as: .zip

Change History (7)

#1 @imath
8 years ago

  • Keywords has-patch reporter-feedback added

Hello Dan,

Can you share how you're excluding a user_id from the friends widget ? I didn't manage to reproduce.

Personally, i think we should include a filter to make this easier.. Attaching a patch just in case.

@imath
8 years ago

#2 @danbp
8 years ago

here what i did with ajax function.

{{{
function bpfr_custom_core_ajax_widget_friends() {
	remove_action( 'wp_ajax_widget_friends', 'bp_core_ajax_widget_friends' );
	remove_action( 'wp_ajax_nopriv_widget_friends', 'bp_core_ajax_widget_friends' );
	
	check_ajax_referer( 'bp_core_widget_friends' );
	
	switch ( $_POST['filter'] ) {
		case 'newest-friends':
		$type = 'newest';
		break;
		
		case 'recently-active-friends':
		$type = 'active';
		break;
		
		case 'popular-friends':
		$type = 'popular';
		break;
	}
	
	$members_args = array(
	'user_id'         => bp_displayed_user_id(),
	'type'            => $type,
	'max'             => absint( $_POST['max-friends'] ),
	'populate_extras' => 1,
	);
	
if ( bp_has_members( $members_args ) ) : ?>
<?php echo '0[[SPLIT]]'; // return valid result. TODO: remove this. NE PAS RETIRER ?>

<?php // ajout de la condition pour exclure l'admin

	while ( bp_members() ) : bp_the_member();
	$exclude_ids = array(1); /* member ids separated by comma to exclude from listing */
	if (!in_array(bp_get_member_user_id(), $exclude_ids)) {
	?>
	
	
	<li class="vcard">
		<div class="item-avatar">
			<a href="<?php bp_member_permalink() ?>"><?php bp_member_avatar() ?></a>
		</div>
		
		<div class="item">
			<div class="item-title fn"><a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_name() ?></a></div>
			<?php if ( 'active' == $type ) : ?>
			<div class="item-meta"><span class="activity"><?php bp_member_last_active() ?></span></div>
			<?php elseif ( 'newest' == $type ) : ?>
			<div class="item-meta"><span class="activity"><?php bp_member_registered() ?></span></div>
			<?php elseif ( bp_is_active( 'friends' ) ) : ?>
			<div class="item-meta"><span class="activity"><?php bp_member_total_friend_count() ?></span></div>
			<?php endif; ?>
		</div>
	</li>
	
<?php } endwhile; ?>

<?php else: ?>
<?php echo "-1[[SPLIT]]<li>"; // ne pas retirer !?>
<?php _e( 'There were no members found, please try another filter.', 'buddypress' ) ?>
<?php echo "</li>"; ?>
<?php endif;
}
add_action( 'wp_ajax_widget_friends', 'bpfr_custom_core_ajax_widget_friends' );
add_action( 'wp_ajax_nopriv_widget_friends', 'bpfr_custom_core_ajax_widget_friends' );
}}}

#3 @DJPaul
8 years ago

  • Keywords has-patch reporter-feedback removed
  • Milestone changed from Awaiting Review to Future Release
  • Type changed from task to enhancement

The underlying "0" or "-1" issue is because of some legacy JS, here: https://buddypress.trac.wordpress.org/browser/trunk/src/bp-friends/js/widget-friends.js?rev=8378#L28

I made a ticket recent #5735 in which we'll use to help modernise and rewrite all our JS, probably starting in 2.2 -- but this issue is going to be around a while longer, I'm afraid. :)

#4 @danbp
5 years ago

Back to the past or returm to the future ? Scratching up this old ticket, as
echo "0[[SPLIT]]"; is still in BP 2.7

  • bp-groups-widget.php:58
  • bp-friends-widgets.php:71

Thanks for #5735 anyway.

#5 @DJPaul
4 years ago

  • Keywords trac-tidy-2018 added

We're closing this ticket because it has not received any contribution or comments for at least two years. We have decided that it is better to close tickets that are good ideas, which have not gotten (or are unlikely to get) contributions, rather than keep things open indefinitely. This will help us share a more realistic roadmap for BuddyPress with you.

Everyone very much appreciates the time and effort that you spent sharing your idea with us. On behalf of the entire BuddyPress team, thank you.

If you feel strongly that this enhancement should still be added to BuddyPress, and you are able to contribute effort towards it, we encourage you to re-open the ticket, or start a discussion about it in our Slack channel. Please consider that time has proven that good ideas without contributions do not get built.

For more information, see https://bpdevel.wordpress.com/2018/01/21/our-awaiting-contributions-milestone-contains/
or find us on Slack, in the #buddypress channel: https://make.wordpress.org/chat/

#6 @DJPaul
4 years ago

  • Milestone Awaiting Contributions deleted
  • Resolution set to maybelater
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.