Comments on: BuddyPress: Sort members by current balance https://mycred.me/tutorials/buddypress-sort-members-by-current-balance/?utm_source=rss&utm_medium=rss&utm_campaign=buddypress-sort-members-by-current-balance Free WordPress Reward, Badge, Loyalty & Points Management Plugin Tue, 22 Mar 2022 14:33:09 +0000 hourly 1 https://wordpress.org/?v=6.6.1 By: ForestNation https://mycred.me/tutorials/buddypress-sort-members-by-current-balance/#comment-62794 Mon, 20 Dec 2021 14:45:47 +0000 https://devstages.wpengine.com/?post_type=tutorial&p=3969#comment-62794 This works well… Anyone know a how to add the points balance to the profile card in the members directory? So we can sort by points and see them for each user.

]]>
By: Allan https://mycred.me/tutorials/buddypress-sort-members-by-current-balance/#comment-62793 Mon, 20 Dec 2021 14:45:21 +0000 https://devstages.wpengine.com/?post_type=tutorial&p=3969#comment-62793 What if you wanted to break it down by dates? So you would get a list of the users their point, but you wanted to calculate their point between 2 dates?

]]>
By: Tomek https://mycred.me/tutorials/buddypress-sort-members-by-current-balance/#comment-62792 Mon, 20 Dec 2021 14:45:20 +0000 https://devstages.wpengine.com/?post_type=tutorial&p=3969#comment-62792 Hi,
i try to use this tutorial, but when i paste a code to function.php files i don’t see any changes.
I use MyCred 1.6.1, WP 4.1.1, Buddypress 2.2.1 and SweetDate theme.

]]>
By: ARCangelGIRL https://mycred.me/tutorials/buddypress-sort-members-by-current-balance/#comment-62788 Mon, 20 Dec 2021 14:45:17 +0000 https://devstages.wpengine.com/?post_type=tutorial&p=3969#comment-62788 Hello,

Code in functions.php is exactly the same as you have provided. I just changed members loop sort desc by default.
This line:

I changed to this:

]]>
By: ARCangelGIRL https://mycred.me/tutorials/buddypress-sort-members-by-current-balance/#comment-62786 Mon, 20 Dec 2021 14:45:17 +0000 https://devstages.wpengine.com/?post_type=tutorial&p=3969#comment-62786 Hello!
Thank you for a great plugin!

I have tried this snippet in order to sort members by they current balance. Paste the code in functions.php and by editing members loop by changing this code

to this (order by points-desc by default)

The problem is that after I did this the stopped working and also pagination at the end of the member list were gone.

How could I fix this, because I would like to order members via they current points balance, but also have the search working.

Thank you!

]]>
By: Gabriel Merovingi https://mycred.me/tutorials/buddypress-sort-members-by-current-balance/#comment-62787 Mon, 20 Dec 2021 14:45:17 +0000 https://devstages.wpengine.com/?post_type=tutorial&p=3969#comment-62787 Hey. Can you please use pastebin or similar for your code. All codes are stripped from comments and I can not see what changes you did.

]]>
By: ARCangelGIRL https://mycred.me/tutorials/buddypress-sort-members-by-current-balance/#comment-62789 Mon, 20 Dec 2021 14:45:17 +0000 https://devstages.wpengine.com/?post_type=tutorial&p=3969#comment-62789 http://pastebin.com/NQ6Zaq2W

]]>
By: Gabriel Merovingi https://mycred.me/tutorials/buddypress-sort-members-by-current-balance/#comment-62791 Mon, 20 Dec 2021 14:45:17 +0000 https://devstages.wpengine.com/?post_type=tutorial&p=3969#comment-62791 Nice job. Maybe it should be wrapped in a function check to make sure the friends module is enabled.

]]>
By: Indeax https://mycred.me/tutorials/buddypress-sort-members-by-current-balance/#comment-62790 Mon, 20 Dec 2021 14:45:17 +0000 https://devstages.wpengine.com/?post_type=tutorial&p=3969#comment-62790 Hi Gabriel, thanks you for this tip. Im starting to play with mycred and it’s fantastic! really a great work, thanks!

I would like to contribui with a correction. when you want to list your friends sorted by balance it don’t work, it’s need to add a filter in the where clause for that. Here is how a did:

// Adjust WHERE
$BP_User_Query->uid_clauses['where'] = "WHERE um.meta_key = 'mycred_default'";

// comprovamos que no sea un filtro de amistad
if ($BP_User_Query->query_vars['user_id']) {
	$fs = friends_get_friend_user_ids($BP_User_Query->query_vars['user_id']);
	$fs = implode(',',$fs);
	$BP_User_Query->uid_clauses['where'] .= " AND u.ID IN ($fs)";
}
]]>
By: Gabriel David https://mycred.me/tutorials/buddypress-sort-members-by-current-balance/#comment-62785 Mon, 20 Dec 2021 14:44:59 +0000 https://devstages.wpengine.com/?post_type=tutorial&p=3969#comment-62785 Okay, for anyone who stumbles across this – here is the solution

simply append a list of IDs to the where statement. The exact code I used will be a little different, but heres the gist:

$ids_to_include = explode("=", $scope);
$ids_to_include = explode(",",$ids_to_include[1]);
$ids_string = "";

$id_count = 0;
foreach($ids_to_include as $id){
	if($id == ""){
		continue;
	}else{
		if($id_count == 0)
			$ids_string .= " AND (um.user_id = ".$id;
		else
			$ids_string .= " OR um.user_id = ".$id;		
				
		$id_count++;
	}
}
if($ids_string != "")
	$ids_string .= ")";	
		
$BP_User_Query->uid_clauses['where'] .= $ids_string;

Where the initial input of $scope is formatted “include=[id1],[id2],[id3]

The count variable is still a bit off based, but that was actually happening from Gabriel’s code so if I find a fix to that I’ll definitely post here (and here and on the buddypress forum topic im opening here: https://buddypress.org/support/topic/how-to-with-gabey-d-adding-location-filtering/ )

]]>