Members loop sorting, friends first in order
-
WordPress 4.5.2
BuddyPress 2.5.2
Theme: Twenty SixteenI try sorting memberl list in certaine papameters:
- Is online;
- Is custom field;
- Is user friends first.
Fist & second params is done.
Thirds condition i try to resolve with this method
Me class variant
In a wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/members/members-loop.php
$user_id = bp_loggedin_user_id(); $friends = friends_get_friend_user_ids($user_id); function display_friends_online($friends){ $result = []; foreach ($friends as $friend_item) { if ( bp_has_members( 'type=online&include='.$friend_item)) { $result["$friend_item"] = $friend_item; } } if (count($result) > 0) { return count($result); } else { return 0; } } $class_members = new BP_Custom_User_Ids(display_friends_online($friends));
I debugged code in xDebug and found that sorts by default its output system kernel.
Friends not first in list.
Please help!
- You must be logged in to reply to this topic.