Overrride buddypress theme function [closed]

You’ll have to substitute $bp->displayed_user->id with bp_get_member_user_id() to make it work within the members loop.

I’m guessing that that function is used in other parts of your theme as well and changing the $user_id variable will probably screw things up, so it might be better to copy that function across to your themes functions.php file. You’ll have to rename the function to avoid any conflicts, change the user id and then use your new function in the members loop.